Run a raycast to see if a theres a ceiling above the player?
-
Run a raycast to see if a theres a ceiling above the player?
-
@NotCrunchyTaco By default the
World.GetGroundHeight()
will return a value higher than the player's position if it hits anything above it.
-
@LeeC2202 Could you provide an example?
-
@NotCrunchyTaco
float _groundHeight = World.GetGroundHeight(Game.Player.Character.Position);
Compare the value with the player's Position.Z value and if it is higher, something is above the player.
I should add though, this will return a value with any map object, which probably includes lamps, signs etc... Then again, the same thing would be true if you were to do a RayCast upwards.
-
@LeeC2202 Ah, Thank you for your help!
-
@NotCrunchyTaco If you are going to use the ground height, I would use the Native to get used to how it functions. The SHVDN version has a flaw in that it always casts the ray from 1000 units up and that means you can't get the ground height if you are under something like a bridge. I would advise using this instead:
OutputArgument _groundZ = new OutputArgument(); Function.Call(Hash.GET_GROUND_Z_FOR_3D_COORD, Position.X, Position.Y, Position.Z, _groundZ, 0); float _groundHeight = _groundZ.GetResult<float>();
With that, you can set the Z position properly, so you can cast the ray from the player's position to get the real ground height where you are standing. Or you can cast it from high up to get a result from above you.
-
@LeeC2202 Hey, Do you know how to detect if the joystick used for walking on a controller is pushed up, left, right, down? I am using:
Game.IsControlPressed(2, GTA.Control.CONTROL)
-
@NotCrunchyTaco I use
Game.GetControlValue(2, Control.MoveLeft)
andGame.GetControlValue(2, Control.MoveUp)
for the left stick andGame.GetControlValue(2, Control.LookLeft)
andGame.GetControlValue(2, Control.LookUp)
for the right stick.That will return a value of 0 - 127 for one side of the axis and 128 - 255 for the other. Even though it is called
MoveLeft
, it still returns a value when you push right.
-
@LeeC2202 I need it for controller support on my flip mod so you can choose the direction with the left stick. Is there anyway to do that?
-
@NotCrunchyTaco I have removed this code so as to not confuse anyone else. As @stillhere has rightly said, use GetControlNormal instead of my lengthy code.
-
@LeeC2202 Thanks! I'll try it out!
-
@LeeC2202 is not GetControlNormal the same as GetControlValue but normalized? I never realized this until I saw your example
-
@stillhere Knowing my luck, that's most likely exactly what it is.
At times, I really do think I should take up texture modding instead.
F%"$!£!
I suspect you can guess what that means.
-
@LeeC2202 don't worry about it! I learned something from your code so it's not all bad