Quantcast

Jump to content

» «
Photo

Get direction from one position to another

4 replies to this topic
LetsPlayOrDy
  • LetsPlayOrDy

    Lets mod or die!

  • Members
  • Joined: 24 Aug 2013
  • United-States

#1

Posted 01 August 2014 - 01:54 PM

Hey guys.

So I'm wondering how you would get the direction from one position (the player) to another position (a car or pedestrian)? I'm trying to make a force field mod.

Thank you for any answers.


AgentWD40
  • AgentWD40

    GLITCHED

  • Members
  • Joined: 02 May 2009
  • Philippines

#2

Posted 01 August 2014 - 03:27 PM Edited by hardsty1e, 01 August 2014 - 03:28 PM.

like so? source code included.


LetsPlayOrDy
  • LetsPlayOrDy

    Lets mod or die!

  • Members
  • Joined: 24 Aug 2013
  • United-States

#3

Posted 01 August 2014 - 03:29 PM

like so? source code included.

Pretty much. Thanks for the link ;)


InfamousSabre
  • InfamousSabre

    Harpocrates

  • Members
  • Joined: 03 Jan 2013

#4

Posted 01 August 2014 - 06:13 PM Edited by InfamousSabre, 01 August 2014 - 06:17 PM.

public Vector3 DirectionToVector3(Vector3 from, Vector3 to)
{
     return Vector3.Normalize(to - from);
}

LetsPlayOrDy
  • LetsPlayOrDy

    Lets mod or die!

  • Members
  • Joined: 24 Aug 2013
  • United-States

#5

Posted 01 August 2014 - 06:24 PM

public Vector3 DirectionToVector3(Vector3 from, Vector3 to)
{
     return Vector3.Normalize(to - from);
}

Already got it from the BlastForce mod, but thank you anyways :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users