0 votes

Hello there,

I have a problem, I have a pickaxe in the players hand that rotates accordingly to the mouse.
I get the collisions using 2 RayCasts on both ends of the pickaxe.
I do this so that I can't move it inwards more, but if the second raycast isnt colliding I can pull it out again.
But when you rotate/move the pickaxe too fast, it will clip too far in the wall, and the second end also collide with the wall, and so I cant move/rotate it out again...

Is there any answer to let the pickaxe stop exactly on the wall/floor?
That would be awesome.

(I'm a not that experienced programmer yet, just so you know)

Kind regards, sian2005

in Engine by (26 points)
retagged by

2 Answers

0 votes
Best answer

I think you need more raycasts.

Maybe something like, if the pickaxe is going to rotate more than a certain amount, split it into two or more segments, and do a raycast in code for each segment to check if it is colliding, and if so, move it to the collision point.

Some info on code ray-casting here.

by (65 points)
selected by
0 votes

Simply give the pickaxe a collision body.

by (526 points)

That doesnt work with the rotation, I have tried that before...

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.