- Home /
Question by
Under-Player · Jul 12, 2021 at 12:17 PM ·
rotationspeed
How to make speed and rotation velocity be proportional by target position,Rotate and move forward to position without doing circles
So, my task is to make a cube moving to some point in the platform. And I want to make a cube moving only in Vector3.forward direction
So, I made this
[SerializeField]
private float speed;
public float Speed
{
get
{
return speed * Time.deltaTime;
}
set
{
speed = value;
}
}
void Update()
{
MoveToPosByAngle(target);
}
void MoveToPosByAngle(Vector3 target)
{
RotateToTarget(target);
transform.Translate(Vector3.forward * Speed);
}
void RotateToTarget(Vector3 target)
{
target.y = transform.position.y;
Quaternion rotateTarget = Quaternion.LookRotation(target - transform.position);
transform.rotation = Quaternion.Lerp(transform.rotation, rotateTarget, 2.0f * Time.deltaTime);
}
My problem is, when the point is very close to the cube it starting to go in circular way without reaching the point
And second question, how to make a cube to move faster at the beginning and to move slower to the point at the end
Comment
Your answer
Follow this Question
Related Questions
How can I rotate at a constant speed to look at a point? 2 Answers
Rotation used as movement 4 Answers
[Solved] How to calculate transition from movement speed to rotation speed? 1 Answer
Dividing the circular rotation into parts? 2 Answers
When applying AddRelativeForce object reaches higher speed when rotated 1 Answer