Answer the question
In order to leave comments, you need to log in
Get displacement vector in NavMesh Unity?
Hello!
I read the Unity documentation, and I realized that you can set a target for the NavMeshAgent, and it will move there. The question arises: is it possible to obtain a correct displacement vector? ATTENTION - not the vector of the current displacement, but the direction in which my object should move.
I will be grateful for any help.
Thank you.
Answer the question
In order to leave comments, you need to log in
I'm not an expert in unity, but I don't know of any specialized team for this. There is such an option:
Vector3 last_position, move_vector = Vector3.zero;
void Start()
{
last_position = transform.position;
}
void FixedUpdate()
{
move_vector = transform.position - last_position; //Определения вектора, направленного от предыдущей позиции к следующей
last_position = transform.position; // Переназначение предыдущей позиции
}
float deltatime, timer;
void Update()
{
if(Time.time > timer)
{
move_vector = transform.position - last_position;
last_position = transform.position;
timer+=deltatime;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question