I need help coding a grapple gun for a 3D game

i’m gonna add a grapple gun, but i don’t know how, and can’t find a topic on the forum

Hi @SnooDev and welcome,

Yes I don’t think you will find a script that can do that already. Start with the learning material on the user manual on scripting:

https://developer.playcanvas.com/en/user-manual/scripting/

From there what I’d do is break down the “grapple gun” concept on what exactly it does on each step and attempt to implement that. You will see then you will have more specific questions which you can post here to get concrete help.

1 Like

I can’t give you a script but I can the general idea of how it should work.

do a raycast in the direction you want to grapple. Pick the collision point, that will be the point where the grapple gun has locked on.

Then keep adding force to the Rigidbody in the direction of the point, you can even keep adding acceleration to emulate the momentum of the Grapple Gun.

When you are close enough to the point, just disable the script and, if you have physics already working for your character, he should start falling.

2 Likes

bump