0 votes

Hi learning godot3

I have a paddle. I can move it with getting mouse coordinates like
Case1:

var mouse_position = get_viewport().get_mouse_position()
set_position(mouse_position)

The problem is my KinematicBody2D will not respect the boundries of a static body, area2d. The body will simple and always follow the mouse.

Case2:

or move it via moveandcollide then it will respect my walls I placed. However if an other object hits my KinematicBody2D this will have physic effect.

How do you handle this. In case1 respect walls or in case2 have no physics on the KinematicBody2D.

in Engine by (75 points)

1 Answer

0 votes

Use move_and_collide and then you can change the CollisionLayer / CollisionMask of your KinematicBody or the other PhysicsBodies to prevent interaction with each other.

Read more about it in the PhysicsBody2D API.

As moveandcollide returns a KinematicCollision2D-Object you can also use the included information there to adapt your bodies behavior.

by (1,030 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.