Grappling Hook -Project

For this project, i wanted to create a gameobject that can swing around by shooting grapping hooks into walls and ceilings. First i created a test-scene, containing sphere -shaped Player character, and some cube-walls to shoot the “hook” into.Screenshot 2015-12-22 18.48.46


Then i created a script that checks if the left mouse button is pressed. If so, it checks where you clicked and shoots raycast from gameobject to where-ever you clicked.

Console prints text “You clicked on [name of the object]”, for testing purposes.Screenshot 2015-12-22 18.53.57


If the object that we clicked has a rigidbody2D component attached to it, script will activate a Distance Joint between them.Screenshot 2015-12-22 18.54.57


 

And when we stop pressing the left mouse button, Distance Joint turns of.
Screenshot 2015-12-22 19.01.41


Distance -value can be changed from the script. This way we can make our Grappling Hook’s “rope” longer and shorter. In this case, i made the “rope” to reel itself in with increasing speed.Screenshot 2015-12-22 19.24.12


 

It’s nothing special, but now we have a very basic shootable Grappling Hook, that we can use to swing around. I’m gonna get some coffee.
insta

Since Unity Engine handles all touch inputs as mouse clicks,
Android build works without any extra work required.

insta

Leave a comment