I am trying to implementwriting a script where basicallythat would make my players would reach thea target destination. Below is my scriptIt looks like this so far:
private void MoveTowardsGoal() { if (Vector3.Distance (reachGoalTarget.transform.position, transform.position) > 2.0f) { rDirection = (reachGoalTarget.transform.position - transform.position).normalized; if (rAcceleration < rMaxSpeed) { rAcceleration += 0.5f; } rVelocity = rDirection * Time.deltaTime * rAcceleration; transform.Translate (rVelocity,Space.World); } } It works fine, the: The objects move towards the destination point. ButHowever, I want them to move looking at the target in the forward direction ( forwardforward z axis ). Currently they move with their x axis facing front.
I tried a simple rotation inside Start()Start() like transform.LookAt(reachGoalTarget.transform)transform.LookAt(reachGoalTarget.transform). With this, they look in the forward direction but then they completely move off their initial positions by rotating themselves to reach the goal.
Please provide suggestions as to what I can change or if IWhat am I doing anything wrong here. Thanks!?