This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+1 vote

how can i make my hitbox position follow my mouse in area2D i set, but if my mouse go outside the area2D i set, my hitbox wont move beyond area2D but still follow the direction?
something like this
enter image description here

in Engine by (429 points)

1 Answer

0 votes

A few different ways to achieve this. A naive approach is to clamp the hitbox distance from the centre of the area (i.e. its radius). You could also create a polygon collider and do it all in editor.

  • Create a Sprite with a texture of that shape (an image of a circle for example)
  • Press Sprite > Create CollisionPolygon2D Sibling

https://godotengine.org/qa/46417/how-to-prevent-player-from-moving-outside-the-shape-or-area

by (1,406 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 Frequently asked questions and 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 [email protected] with your username.