• Register
Forum Thread
  Posts  
Making a grappling hook in Unity 3D (Forums : Coding & Scripting : Making a grappling hook in Unity 3D) Locked
Thread Options
Jun 28 2016 Anchor

I am currently working on a game that is similar to a cross between Assassin's Creed, and Tomb Raider. Long story short, I am having trouble trying to find what I am looking for. The theory is to trigger an animation followed by the shooting of the hook, then a travel animation as the player character travels towards the anchor point. The final thing that I would want is the character to stay connected to the object until Fire2 is pressed again. I have basic knowledge of Unity as an engine, But am relatively new to coding.

Jun 30 2016 Anchor

I would raycast from the center of the screen, check if the surface is grappleable. Then "lerp" a position 2 in a line renderer towards the hit.point. After that just use the physics to pull the player to the grapple point. Disabling the controls whilst in the air.

Aug 10 2016 Anchor

You need to define which objects can be grabbed and which can't. fine?
how will you do this?
Assuming the camera is controlled by the mouse like assassin's creed, Raycast to the object pointed at to check if it can be grabbed

then the animator makes an animation of the hook getting out of the hand or whatever

play it if player clicks the button that grabs maybe "FIRE1" , Animation["HookExtraction"] plays , instantiate the hook with a script that makes it does "whatever" maybe pull something, so it needs to be a collider and the grabbed object needs to be a collider too.
then void OnTriggerEnter(Collider other)

{

//after hook instantiation, play the animation of Grabbing the thing wanted

vector3 otherTransform = new vector3(playerRB.x + "some space" ,0.0f "if not in mid air" ,playerRB.z + "some front space");

other.transform = otherTransform;


play "grabbed animation"

// x can be 0.0f if you want the object to be grapped exactly infront of you, so you use z-axis only

}

now to OnTriggerStay(Collider other)
{

//Add a fixed joint by class Joint , attaches your player and the object

}

OnTriggerExit(Collider other)
{

//what happens after the object is left? or left maybe by accident

}

Forgive me if I missed something.

--

Facebook >> A7mdxp2d

Sep 1 2016 This post has been deleted.
Sep 18 2016 This post has been deleted.
Reply to thread
click to sign in and post

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.