Collision help please

Godot Version

4.2.1

Question

is there a way for me to do like ‘on space clicked but only while in a certain collision area’

You could do a two step process.

  • Keep track if you are in a certain collision area with a boolean value
  • When space is clicked, first check the value of the boolean before acting on it.

What you mean with “while in a certain collision area” is a bit ambiguous:

  • if you mean the mouse cursor is in the area of a CollisionObject2D or CollisionObject3D, then you can listen to the signals mouse_entered and mouse_exited for adjusting the boolean value.
  • if you mean, that a second CollisionObject is in the area of the specified CollisionObject, then you need to use the respective functions for adjusting the boolean value.

its another collision area, would u mind giving a bit of example code is possible?

Haven’t used that functionality in a while.

You might be better off to look at the docs.The topic of colliding physics objects is covered in the “First 2D game”.

oki thank you!

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