if (this.entity.getPosition().y < 10) {
this.entity.setPosition(0, 21, 0);
}
Why won’t this work? What’s wrong with it?
The game is a platformer set at about y=20, so when you fall, shouldn’t this trigger?
Full game can be found at the link below
https://playcanvas.com/project/1036368/overview/game
EDIT: BTW, I have no idea why it forces you to jump when you fall far enough. It’s not caused by the main jumping script (I tested)
Hi @P0werman1!
Because you use a dynamic rigidbody you need to teleport the rigidbody of the entity instead of changing the position of the entity.
this.entity.rigidbody.teleport(0, 21, 0);
1 Like
Thank you! I didn’t know that.
Also, what could be causing the jumping when you hit the bottom?
I don’t see the jumping.
I only see the fall animaiton from the falling before the teleport, I think that’s as expected?
Why the player movement is not smooth anymore? Did you change anything in movement?
I just implemented the code you recommended, but before that, when you fell far enough, it would start forcing you to jump when you hit the bottom.
Also, can I make the camera smoothly transition back when the player dies instead of a hard teleport?
This requires some script work, which unfortunately I can’t help you with.
Is there a way I can find the distance between the player and camera? I’m just going to make it smoother if it’s more than a certain distance away.
Thank you, and I have no idea. It works the same on my device as before.
Probably my screen has a higher refresh rate. Yesterday the movement was smooth.
Checking your last changes for movement and camera movement.
Was it player or camera movement that was bad? Or could you not tell?
Right now the position of the player entity and the camera entity are both set in the update function. This happend at the same time and because you use the player position to set the camera position, this can cause the glitch I see. Maybe you can try to change the position of the camera in the postUpdate function instead of update function. For this you need to change the name of the update function of the camara script to postUpdate
.
I apologize for the delay, and thank you! I got that working, now I’m just working on the “smoothening” that I mentioned for when the player dies (camera might be looking funky right now)