If you get an error saying getPosition is not defined, then findByName is not finding an entity in your scene called test. Double check the naming. For example, did you perhaps name it Test?
Hello @Dann! I’ve looked at your project and as far as I can tell it’s almost okay. I don’t think you can use setPosition() in this case. You have to use teleport() if you are using a dynamic rigidbody. Also test() is not a function in your project so you have to remove this line or create a function with this name.
Try replacing this code:
else if(entity.other.tags.has("player")){
var test = this.app.root.findByName("test").getPosition();
entity.other.setPosition(test);
console.log("hit");
test();
}
with this:
else if (entity.other.tags.has("player")) {
var test = this.app.root.findByName("test").getPosition();
entity.other.rigidbody.teleport(test);
console.log("hit");
}
i think it’s not working with rigidbody dynamic collider with rigidbody kinematic.
but if i do this it’s working when dynamic collider with kinematic
else if(entity.other.tags.has("player")){
var test = this.app.root.findByName("test").getPosition();
entity.other.setPosition(test);
console.log("hit");
test();
}
it is solved if my character rigidbody type is static or kinematic, but if I change my rigidbody character type to static or kinematic the jump function doesn’t work, because the jump function requires a dynamic rigidbody type
You have to determine what is the best option for your game. A player with a kinematic rigidbody or a player with a dynamic rigidbody. Then you have (re)make the others functions, like your jump function, so that everything is working for that type of rigidbody.
If you keep the player with the dynamic rigidbody body, did you already try the code that I sent to you?
But I assume this is not what you want as it will broke your other functions? If you add me to the project with write access it’s easier for me to debug why it’s not working with the player that has a dynamic rigidbody.
anyone help please i dont know this is bug or not. why my character with rigidbody dynamic collider with entity rigidbody kinematic it can’t teleport. i trying to change my character rigidbody to kinematic and my entity to dynamic teleport is work If I do that, my character can teleport, but this is not what I want
It took a while, but I found out that the update function of your playerMovement script hinders teleporting. I therefore added an extra boolean and set it just before teleporting. With this boolean I block the update function of your playerMovement script. Then it works as expected. The reason why it also works after an error is because the error also stopped the update function of your playerMovement script.