Need help with MoveTo math...

Post » Wed Jun 20, 2012 4:52 am

I have a target actor that I need to move the player to, such as this:

  Player.MoveTo(akTarget,afxOffset = -100,abMatchRotation = true)  Game.ForceThirdPerson()   int random = Utility.RandomInt(1,3)  if(random ==1)   akTarget.PlayIdle(IdleWounded_01)  elseif random == 2   akTarget.PlayIdle(IdleWounded_02)  Else   akTarget.PlayIdle(IdleWounded_03)  EndIf  utility.Wait(3.0)  Player.PushActorAway(akTarget,0)

What I have no idea is the math involved to calculate how to determine a position X distance away but directly behind the actor, regardless of his heading. Any math geniuses or just better educated people that can lend a hand?

Thanks,

- MM
User avatar
Dewayne Quattlebaum
 
Posts: 3529
Joined: Thu Aug 30, 2007 12:29 pm

Post » Wed Jun 20, 2012 5:59 am

Its not so hard. I use this for my horse summon.
It works on a 90 degree angle setting, and places the horse in front of you based on that.
Reverse it for placing behind.

myZ = Game.GetPlayer().GetAngleZ()if myZ >= 315 || myZ <= 45   LevelersNightMareREF.MoveTo(Game.GetPlayer(), afYOffset = 400.0)elseif myZ > 45 && myZ <= 135   LevelersNightMareREF.MoveTo(Game.GetPlayer(), afXOffset = 400.0)elseif myZ > 135 && myZ <= 225   LevelersNightMareREF.MoveTo(Game.GetPlayer(), afYOffset = -400.0)elseif myZ > 225   LevelersNightMareREF.MoveTo(Game.GetPlayer(), afXOffset = -400.0)endif
User avatar
Lisa Robb
 
Posts: 3542
Joined: Mon Nov 27, 2006 9:13 pm

Post » Wed Jun 20, 2012 1:39 pm

From looking at what you posted of your script, I think you're trying to make it look like you snuck up behind an NPC and hit him/her on the head? If that's so, I think you need the script to place you exactly in the 6 o'clock position. That calls for trigonometry, and this is what I always use for doing that:

float anglez = akTarget.GetAngleZ() + 180.0;or +90 for right, -90 for left, 0 for in frontfloat distance = 100.0float offsetx = distance * math.sin(anglez)float offsety = distance * math.cos(anglez)Game.GetPlayer().MoveTo(akTarget, offsetx, offsety, 0)
User avatar
xxLindsAffec
 
Posts: 3604
Joined: Sun Jan 14, 2007 10:39 pm

Post » Wed Jun 20, 2012 5:27 pm

WillieSea and RandomNoob. Thanks guys. I'll give both a try and make appropriate tweaks. Thank you so much.

RandomNoob, that's effectively what I'm doing. The player can only do this when not detected by the victim, and effectively isn't intended to be used when forward facing. I just need to make a small locational adjustment so that the animations that both perform look good and ensuring that the player is behind the victim will do just that now that I've got the timing down. Thank you again!!!

-MM
User avatar
Teghan Harris
 
Posts: 3370
Joined: Mon Mar 05, 2007 1:31 pm

Post » Wed Jun 20, 2012 12:56 pm

Couldn't you just use the GetHeading function and rotate it by 180 degrees?
User avatar
Katey Meyer
 
Posts: 3464
Joined: Sat Dec 30, 2006 10:14 pm

Post » Wed Jun 20, 2012 8:35 am

Hey Redwood. Well, I actually need the player to be facing the same direction as the victim, I just need to make sure they're right behind the victim so the animation pairs up as it's not a paired animation. I'm using two seperate animations with some specific timing. Perhaps I'm misunderstanding you? BTW, love your work!

Thank you again RandomNoob! That code worked flawlessly!
User avatar
Jessie Butterfield
 
Posts: 3453
Joined: Wed Jun 21, 2006 5:59 pm


Return to V - Skyrim