Obtain direction from a point relative to another point

First, srry for bad english isnt my primary lenguaje

im having trouble trying to get the direction of a vector 3 point.

i have touchphase and a raycast, so i want to take the point of touch and make my character jump in that direction. Everything is working fine, but my character jump in a diferent direction.

i think it is happen because the direction is based on the 0,0,0 point,

what i need to do to make the direction relative to the current character position?


Assuming you are in a top down view and you want your character to move/jump in the direction you touched I would first make the character look at the spot touch using transform.LookAt(touchedPosition); and then you can move your character using on his Vector3.forward…

The question is too vague - you should post your script.

Anyway, in most cases you should do something like this:

function Update (){
  if (Input.touchCount > 0){
    var touch: Touch = Input.touches[0];
    if (touch.phase == TouchPhase.Began){
      var ray = Camera.main.ScreenPointToRay (touch.position); // get a ray from the touch
      var hit: RaycastHit;
      if (Physics.Raycast(ray, hit)){ // if the ray hits something...
        // hit.point contains the 3D point clicked
        // jump to this point

For the basics, the vector from A to B is B - A. For something more pratical, see aldonaletto’s answer.