[solved] Move toward a position without rotating and stop if you hit anything, ignore physics

Godot Version

4.2.1 Stable, Linux appimage

Question

Hi, I’m trying to implement an “attraction” function in my game - press a button, and you’re moved toward a position - press it again whilst being “attracted” and you’ll drop down, normal physics come back. If you hit anything, you stop.

I’m trying to get this to work but it seems positions are offset…
Here’s some diagrams I mockedup



Here’s the project:
https://files.catbox.moe/6poycd.zip

Thanks,
Hazel

be careful with child transforms! remember that while your parent node has a position, each child also has a relative position to their parent. so for example, your player node (the one with the script) has a collision polygon child that’s offset (moved way down from the center of) the parent!

image
make sure to check the transform on all of your children. i’d recommend having your collider centered inside of the parent node

same for your magnet. the actual parent node is wayyy up and to the right of where your collider child is

since your script is using the global_position of the parent nodes, it’s expecting your player and magnet to be way up at the origins, which is why your motion script is offset

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.