Jump to content

How do I spawn an actor behind teh player?


Cobal

Recommended Posts

I would like to spawn an actor about 70 units behind the player and almost instantly kill it.

Everything is working fine except for the fact that I can't figure out how to find the coords of a point that is currently behind the players heading.

 

I can get the players angle, I can get the players location. Moveto allows only for absolute offset.

 

ANyone have a clue how I can do this?

 

[edit]Oh goody my fat fingers made my usual typo with "the" in the title. Title doesn't seem to be editable :( [/edit]

Edited by Cobal
Link to comment
Share on other sites

Something like this ...
float fAngle
float fSin
float fCos
float fHeight
fAngle = Game.GetPlayer().GetAngleZ() + 180.0
fSin = Math.sin(fAngle)
fCos = Math.cos(fAngle)
fHeight = Game.GetPlayer().GetPositionZ()
pMyNPC.MoveTo(Game.GetPlayer(), 70.0 * fSin, 70.0 * fCos, fHeight, False)
Note that the correct height of "ground level" at 70 units behind the player's character is not handled by the code snippet above. Might actually be higher or lower than the player character's, depending on the nature of the terrain. So that is something for you to resolve in your own final scripting.

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...