[C#] Placing a Marker in front of your character? (Solved)
-
I'm trying to spawn a Marker in front of the player, but I can't figure out how to deal with the Heading.
This is the marker I was able to spawn:
I have the following code to spawn it:
Ped player = Game.Player.Character; posicion = player.Position; posicion.X = posicion.X + 1.5f; posicion.Y = posicion.Y + 1.5f; posicion.Z = posicion.Z - player.HeightAboveGround; direccion = new GTA.Math.Vector3(f0, f0, f0); rotacion = new GTA.Math.Vector3(f0, f0, f0); escala = new GTA.Math.Vector3(f1, f1, f1); GTA.World.DrawMarker(MarkerType.VerticalCylinder, posicion, direccion, rotacion, escala, Color.Green);
AFAIK it has something to do with the player heading or the forward, so the marker turns around automatically and always being in front of the player.
Thanks in advance!
-
@EnforcerZhukov You can use
Game.Player.Character.GetOffsetInWorldCoords(new Vector3(X, Y, Z))
whereY
is how far in front/behind you want the marker to appear.Those numbers are basically X (Left and Right), Y (Front and Back) and Z (Up and Down)
So for example:
Game.Player.Character.GetOffsetInWorldCoords(new Vector3(0f, 10f, 5f))
Would get a position 10 forward of the player and 5 up.
-
@LeeC2202 said in [C#] Placing a Marker in front of your character?:
@EnforcerZhukov You can use
Game.Player.Character.GetOffsetInWorldCoords(new Vector3(X, Y, Z))
whereY
is how far in front/behind you want the marker to appear.Those numbers are basically X (Left and Right), Y (Front and Back) and Z (Up and Down)
So for example:
Game.Player.Character.GetOffsetInWorldCoords(new Vector3(0f, 10f, 5f))
Would get a position 10 forward of the player and 5 up.
Thanks m8, it works perfectly now!
This is the final code I used, just in case somebody comes here having the same question:
Ped player = Game.Player.Character; posicion = player.GetOffsetInWorldCoords(new GTA.Math.Vector3(0f, 3f, 0f)); posicion.Z = player.Position.Z - player.HeightAboveGround; direccion = new GTA.Math.Vector3(0f, 0f, 0f); rotacion = new GTA.Math.Vector3(0f, 0f, 0f); escala = new GTA.Math.Vector3(1f, 1f, 1f); GTA.World.DrawMarker(MarkerType.VerticalCylinder, posicion, direccion, rotacion, escala, Color.Green);