Hi there.
I have been creating a mod and at the moment you need to type /pvp "playername", problem is some people have non english name and even with partial name function uncluded this is an issue, the other issue is you have to be within a range for my mod to work, so common names is causing to much delay for people to type the partial name that is unique.
So my solution is to make the system easier by using /pvp and having the mod cast a ray or cone (or something) in front of the player and detacting any players in front of the player and passing back there Baseplayer value to run the rest of my code.
Does anyone know if Raycast is the best way to do it, if not what would be and where could I go to get some examples.
Thanks
Baseplayer from raycast or other?
Discussion in 'Rust Development' started by Alphawar, Mar 23, 2016.
-
The players must be in front or around of the command user?
if around you could check for the players in a radius relative to the command user:
Code:// Radius players must be relative to the command user float radius = 300f;// Loop through all players foreach (BasePlayer player in BasePlayer.activePlayersList) { // Distance between the command user and player float distance_between = Vector3.Distance(user.transform.position, player.transform.position); // Compate if distance is minor or equal to the radius if (distance_between <= radius): // DO WHATEVER }Last edited by a moderator: Mar 23, 2016 -
Firstly thanks for your time
I could do that and for the time being I was going to to use the ent collision part that I made to scan for any building part next to player (it is similar to what you recommended), but the reason I was wanting a cast (preferable a cone to make aiming a bit easier), I would prefer this as I have to check if they are friends for each person added in the radius, so im trying to narrow it down.
But if no one else has any ideas of a cone collision to get players in front that's cool and ill just have 2 bite the bullet and really clean up my code to make more functions
Thanks again though -
Well once someone told me to try to use Raycast Sphere or something (I assume its this Unity - Scripting API:, but im not sure about it), and then someone else told me that would be a bad idea for what I needed, so then that someone recommended me the code above basically which suited best for the job, however I'm not sure if this would be good for you or not.
But good luck anyway -
Thanks, ill let you know how it goes and ill show you the code I end up going with.
