Search Unity

  1. Get the latest news, tutorials and offers directly to your inbox with our newsletters. Sign up now.
    Dismiss Notice

Resolved Make a object move towards another object

Discussion in 'Visual Scripting' started by vs_volgin, Nov 24, 2020.

  1. vs_volgin

    vs_volgin

    Joined:
    Nov 24, 2020
    Posts:
    3
    Hello.

    I need help on how to make an object move towards another object using bolt visual scripting.

    The movement that i want is based on the code below. I got this code in an YouTube video, but i couldn't follow the logic with bolt flow graph:

    public class MovingAntibody : MonoBehaviour {

    public GameObject player;

    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update() {
    transform.LookAt(player.transform);
    transform.position += transform.forward * 1f * Time.deltaTime;
    }
    }

    Here is how i tried to make the movement in bolt, but failed.

    upload_2020-11-24_15-37-27.png

    upload_2020-11-24_15-38-10.png

    Any help will really be appreciated.
     
  2. ericb_unity

    ericb_unity

    Unity Technologies

    Joined:
    Nov 24, 2017
    Posts:
    65
    Not exactly what your is doing, but this is a way to make it work.
    upload_2020-12-4_10-17-13.png
     
    vs_volgin likes this.
  3. vs_volgin

    vs_volgin

    Joined:
    Nov 24, 2020
    Posts:
    3
    Thank you for trying to help me. Your flow graph made the object move towards the target, but it doesn't follow the target if its a moving target.

    I need to do something like an enemy chasing a player that is moving. That means - i need to make a object follows another object wherever it goes.
     
  4. ericb_unity

    ericb_unity

    Unity Technologies

    Joined:
    Nov 24, 2017
    Posts:
    65
    Actually this script make the object always moving to the target position. MoveTowards.gif
     
    vs_volgin likes this.
  5. vs_volgin

    vs_volgin

    Joined:
    Nov 24, 2020
    Posts:
    3
    It worked! I had a problem with the object reference.

    Thank you very much.!
     
    ericb_unity likes this.
unityunity