i actually defined lookTo right after and it didnt help
What is the error? Please show your script again.
Still that cant getposition of undefined , strange…
https://playcanvas.com/editor/scene/1025730
here you can check my scene and scripts within
I’m on my mobile right now. Maybe it’s better that you explain how your target index system is working, because something is wrong with that. I think if you use a simple position of an entity in your scene, it’s working.
Yep, i want my player smoothly rotate towards his waypoint because now he is rotating immediate without any smoothnes and that is not nice, somebody said that i even can use math.lerp, i think it is not that bad idea
There is used lookAt function now
Great, but that’s no answer on my question.
Honestly I understand just in general how it works, i was asking on smooth look at and somebody refered a script to me, its from tween library
I will advice to create first one waypoint in your scene with the name “Waypoint”. In the initialize function you add the line this.waypoint = this.app.root.findByName(‘Waypoint’);
and you replace the line with the error with this.lookTo.copy(this.waypoint.getPosition());
. Then see what is the result.
Why is it that I am controlling the red model with the enemyAi script and not the blue model with the playermovement?
There is no error now, it was needed to delete targetIndex probably
that variable was the only thing i didnt understand, and i still dont
You control red player with W and Blue player with Up arrow
What do you mean?
still tweaking lots of stuffs but need my player to rotate smoothly though
Probably that’s a variable that’s used in another game or example, but not in your project. In your project it didn’t exist and that’s why it gives the error of ‘undefined’.
Yeah that makes sense, gotta be more careful next time, although that smooth rotation is not working at all, got no error but neither got my function working
So what is happening?
no clue, i would rather use math lerp it is also easier to understand, now i have no idea idea what is happening inside
What is happening outside?
He is not rotating towards points i defined.
if i use simple lookat it is rotating good, but with no smoothnes.