Search Unity

Move towards area above object

Discussion in 'Scripting' started by polimerjones, Jun 13, 2018.

  1. polimerjones

    polimerjones

    Joined:
    Jun 11, 2018
    Posts:
    5
    I am trying to use vector3.movetowards and going towards target.postition.

    Transform.postion = vector3.movetowards(transform.postion, target.postion, speed)

    I am trying to find out how I can modify this so that the object moves towards the target.postion but slightly above. I basically want to add .7 to the y axis of the target.postion.

    Any pointers would be greatly appreciated.
     
  2. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Well, you'd want to do exactly as you said.
    Code (csharp):
    1. Vector3 actualPosition = target.position;
    2. actualPosition.y += .7f; // use this now instead of target.position
    Something like that? :)
     
    polimerjones likes this.
  3. polimerjones

    polimerjones

    Joined:
    Jun 11, 2018
    Posts:
    5
    Thank you! Worked perfectly.