Occasional failure of character movement

I added a script to the enemy。
Cube
Sometimes rigidbody.teleport() don’t work。
https://playcanvas.com/project/890670/overview/third-person-controller

Hi @hello,

What are you trying to do? Your trigger works quite ok, but if you are trying to teleport the player I think that won’t work like that.

Because the PlayerMovement.js script already teleports the player per frame when he is moving, so it will override your teleport() call.

1 Like

Yes, but how to avoid being affected by the PlayerMovement.js script?

You should add some logic that does that. For example as soon as the object enters the trigger, notify the PlayerMovement.js script that it should stop teleporting the player / stop movement.

Check this manual page on how to communicate between scripts:

https://developer.playcanvas.com/en/user-manual/scripting/communication/

1 Like