Hello,
I am working on a simple project where I move a character with external input. I want my character to move to a specified point. To keep it short I just imported the Standard Assets and used the Ethan-Model for that. I thought, it would make everything easier if I work with the given character controller etc. Here is my code so far:
// move it
public void MoveCharacterToPoint(Vector3 point)
{
// compute difference between current position and targeted position
var offset = point - transform.position;
// check if the distance is far enough
if (offset.magnitude > 0.1f)
{
// normalize offset und multiply movement speed
offset = offset.normalized * moveSpeed;
Debug.Log("Move Character...");
// issue move command
m_Character.Move(offset, false, false);
// move testobject
testCylinder.transform.position = new Vector3 (x, y, z);
}
}
I am having trouble making my character move correctly with that code. Using this my character my character moves to the given point normally and then “dances” around the given point. It seems like Unity doesn’t realise that my character reached the destination already.
I have also tried to multiply the offset with DeltaTime. In that case the character moves very, very slowly, almost not noticable, and an increase of the movement speed has no effect.
I would greatly apprediate hints on how to solve this.