Game Development Community

Programming a Gravity Gun

by Chad Kilgore · in Torque Game Engine · 07/18/2007 (1:38 pm) · 34 replies

I am trying to program a would-be gravity gun but am having some problems in the direction that I am taking. Using part of the Item Collision (specifically a variation on the BlockWeapon::throwBlock function), I am easily able to push objects away from me.

My idea for pulling objects towards the player is to use a path marker mounted at the muzzle point and then assign the selected object to follow the path to that marker. What do people think of this idea? Or does somebody see an easier (or already implemented) way to have a weapon similar to the Half-Life 2 gravity gun? Thanks everybody.
Page«First 1 2 Next»
#21
07/19/2007 (8:14 am)
Oh and it helps if the actual DTS object has been configured correctly for a rigid shape object (i.e. a mass node etc).
#22
07/19/2007 (8:18 am)
@Tim

Ok. My vid is up on my server. I'm not sure how to make my link have those cool thumbnails like yours. I slowed the timescale down to 0.5 to show off the effects. By the way, please excuse the ugliness of this video. :)

www.solforge.com/gg/gravgunandforcegun.jpg

P.S. Whoohoo. This url image link thing works. Thanks again Tim.
#23
07/19/2007 (8:31 am)
Sweet video, that buggy got the crap knocked out of it! I see I'm not the only one mounting dual images, nice :)

Re image URL's

[url=www.yourDownloadLink.com][image]www.yourImageURL.com[ /image][ /url]

Something else that comes in handy, especially for blogs, is:
  • unordered
  • lists
and

  1. ordered
  2. lists
This equates to (minus the spaces in the tags of course):
[ ul]
[ li]unordered
[ li]lists
[ /ul]
and
[ ol]
[ li]ordered
[ li]lists
[ /ol]
#24
07/19/2007 (8:57 am)
@Tim

Yeah dual mount scripting is cool. It's *way* easier than alternate fire coding. Yes, I'm that lazy. :)

Your grav gun grab code doesn't cancel out inertia yet, so when I blast the buggy and yank it back, it still wants to expend all that kinetic energy. I'm looking for a way to kill the intertia, but haven't figured it out yet. Once that's eliminated and the jerkyness for long-term grabs, I think you've got an excellent HL2 Grav Gun replacement. I'll keep looking for a solution to it. I'm thinking after a successful grab, then a quick gettransform and a set transform combo will work, but I haven't tried it yet.

As for Phys Gun effects, several months ago, I stumbled on a cool psuedo physics TGE quirk while playing with rigid-body objects and variable-depth water blocks. Here's a vid of it in action. Note that this is using default Torque physics code, no ODE, no PhysX.

www.solforge.com/gg/phunwithphysics.jpg

P.S. I'm almost hopeless with this forum tag stuff. So, a big thank you for the primer -- I'll give this another try.
#25
07/19/2007 (2:55 pm)
Can I mount two different WeaponImages to the same mount node? Or do I have to use two separate nodes placed on top of each other?

And thanks everybody for the help.

@ Aaron
Would you be willing to post any code snippets from your first demo?
#26
07/20/2007 (6:54 am)
@Chad

Sure, no problem. I'll just need to clean up some of my ugly code and move things around a little bit. After playing with Tim's grav gun code and revisiting my force gun scripts, I ended up spending a *LOT* of time playing and tinkering with new variations of all this. Very fun stuff.

One of the toys I built for this is a spherical shield that is basically a vehicle with a round collision mesh, almost no gravity of its own and one mount node. This 'bubble shield' works great for blocking projectile attacks while I'm holding it out in front of me. And it can also be used to capture AI units and let them float around.

The near zero gravity and spherical collision mesh of the 'bubble vehicle' makes it easier to grab hold of initially and hang onto indefinitely.

Anyway, I'll post some scripts and new vids of all this later on today.
#27
07/20/2007 (7:03 am)
Is there rigidshapes in tgea?
#28
07/20/2007 (8:02 am)
MB,

I don't use TGEA very often anymore, but it should have rigidshapes in there. However, Tim's script will work with all kinds of objects as long as you know the mask name for them. For example, in the script he posted above you see . . .

if(%targetID.getClassname() $= "RigidShape")

But you can extend that with double pipes (||) and include lots of other classes as well. For example . . .

if(%targetID.getClassname() $= "RigidShape" || %targetID.getClassname() $= "wheeledVehicle" || %targetID.getClassname() $= "FlyingVehicle" || %targetID.getClassname() $= "AIPlayer")

So you could use this gravity gun technology to grab AI turrets and manhack drones (like in HL2) or other players if you want. It's very cool to see this in action.
#29
07/20/2007 (8:49 am)
Aye, I restricted the search to a RigidShape object as it works best with them (due to the physics).

You can also expand the search with different masks:
//   $TypeMasks::ShapeBaseObjectType

//   $TypeMasks::PlayerObjectType
//   $TypeMasks::CorpseObjectType
//   $TypeMasks::VehicleObjectType
//   $TypeMasks::TurretObjectType

//   $TypeMasks::InteriorObjectType
//   $TypeMasks::TerrainObjectType
//   $TypeMasks::WaterObjectType

//   $TypeMasks::StaticShapeObjectType
//   $TypeMasks::StaticObjectType
//   $TypeMasks::ItemObjectType
//   $TypeMasks::StaticTSObjectType
//   $TypeMasks::StaticRenderedObjectType
Most objects fall into the 'ShapeBaseObjectType'.
#30
07/20/2007 (8:53 am)
I also read you can put "-1" like:

%searchMasks = -1;

And it will look for every type there is. Not sure if thats the right way to do it, just something I saw someplace. I'm just wondering why I couldn't get rigidshape to work in tgea.
#31
07/20/2007 (8:57 am)
I don't own TGEA, maybe rigid shapes didn't make it into TGEA. Is the source code for them present?

P.S. Torque rigid shapes are just a bastardized version of a hover vehicle - if you really wanted to you could just use a vehicle in place of rigid shapes for a quick test.
#32
08/29/2007 (10:20 am)
@Aaron
I've taken this up from Chad and was wondering if you ever figured out how to kill the object inertia when you pull it back in with the grav gun.
#33
09/16/2007 (8:53 pm)
@ Tim Heldna
has anyone made something like that in a resource for torque, like the gravity gun your friend did on that video?
#34
09/16/2007 (9:00 pm)
No, that was done in another engine.
Page«First 1 2 Next»