Parent inherit from child rigid body.


I am trying to figure out something that is probably simple ( I hope). So the scenario is this way:

I have a player that shoots a grappling hook into a wall.
The Grappling hook becomes a child of the wall ( this is for scenearios where there is a platform).
On certain instances there are vertical platforms that need to be pulled, how can i provide force on the child, which is currently being set to kinematic, to pull the larger heavier object?

So here is the hiearchy:

Player > Shoots GRappling Hook
Oncollision > Parent to whatever hit
Player moves back providing -ve forve on the grappling hook, which is kinematic ( so useless).

Player ends up pulling platform that is a rigid body.

Sorry if I am unclear.


Well, I’ve never made a grappling hook, but I have thought of ways how to do it. I did see a example project (couldn’t see the scripting though) of this being done, so I can think of how it may have been done.

First off, I wouldn’t parent the hook to the object your firing to. I would instead just freeze its position using scripting so that it stays in place. If your not going to swing on the rope, I would just change the velocity of the player to go up, ignoring gravity (not colliders mind you), and just shrink the rope (if its segmented, remove them 1 by 1). Then simply check if I’ve reached the top, and then re-load the hook.

If you are going to make a swinging grappling hook, that is much more difficult. I would calculate the perpendicular (to the vector that represents the hook’s relative position) force applied by gravity to your character. Don’t forget tension, which always points toward the hook.

I’m assuming you have the physics knowledge and the scripting knowledge to follow my advice. If you don’t understand anything, simply ask me to elaborate.

Hope this helps! :slight_smile:

EDIT: Sorry for getting your question wrong. Wasted both of our time :confused: Now…

Ah, yes. I’ve done this before. First you must find the direction you want to pull it. If its a “stiff” rope, you just calculate the direction to the player. If it’s a loose rope, you calculate the direction to first part of the chain. Should be easy enough, so I wont elaborate; you probably you know this already.

The part your probably really looking for is this; Rigidbody.AddForceAtPosition. This will give you that movement you wanted. You can always do it by hand by using AddForce, AddTorque, and centerOfMass. By hand is simply adding the force in the direction of your choosing, and then calculating the proper torque by using the center of mass. If you don’t know how to do that second part, look it up here on wikipedia. That should be everything you need to know. Oh, and make sure that the hook follows and stays in contact with the object that your pulling. Make the hook rotate along with the object (or don’t), and move the hook the same direction as you are moving the table.

I really do hope this solves everything on this problem. Put a lot of effort into it. :stuck_out_tongue:

Good luck!