Gravity Tool


Welcome to our first devlog. I will be talking about one of the first features of our new game we are working on Pipe Dream! The mechanic I will be talking about today is our Gravity Tool. It will have a ton of use in the game and will be required to progress.

Planning

The first thing I did when coming up with ideas to create this tool was research. Research. Research. Research. Garry's mod gravity gun heavily inspired the gravity tool we want to implement into our game. So naturally, the first place to research was to see how the Garry's mod gravity gun worked. After looking through a few videos and tutorials I felt I had a solid plan on how to start. 

Garry's Mod Gravity Gun

Garry's Mod gravity gun

Moving an Object

I identified the easiest way to start would be to first implement being able to pick up, move, and drop the object. First, I need to find out what the player's cursor is pointing to on the screen. For that, I did a ray cast that only searched for objects on a custom layer called "PhysicsInteractables". The ray cast got me all the information I would need including the rigid body of the object selected. Once I had the rigid body,  all I had to do was set the grabbed object's position to a predetermined point in front of the player. Then to let go of the object, all I do is check a rigid body variable and see if it has an object attached to it. If it does, then I can let of the rigid body by not updating its position anymore.

Moving an object

A picture of a cylinder that has been picked up by the player

Rotating an Object

For rotating an object, I decided it would be easiest if there was a "Rotate Mode" that you can toggle on and off by pressing "R".  After toggling on rotate mode, you can use the WASD buttons to rotate the object up, down, left, and right in 90-degree intervals at the moment by changing its transform. While in the rotate mode, I also have to talk to the player movement script to make it so that the player is unable to move while rotating an object. 

Rotating an object

A picture of the player holding a rotated cylinder that has been picked up

Thanks for reading. We will be back next week with more things to show off!

Get Manic Media's Mechanical Mayhem

Leave a comment

Log in with itch.io to leave a comment.