Game Development Community

Platforms Players can Ride Version 1.1

by Cinder Games · in Torque Game Engine · 01/27/2007 (4:34 pm) · 268 replies

Platforms Players can Ride Version 1.2!!!!!!
with Dynamic object Attachment
###################################
##This post has been edited and updated 2/13/07 ##
##################################

subvoicestudios.com/~ramensama/TorqueDynamicAttachment.jpg

Here's the new and improved files you'd need.
Version 1.2
subvoicestudios.com/~ramensama/torque1.5.2.zip

1.7.2008
What's new? There are several new features and improvements.

1) Removed or reduced jitter caused by multiple players on a platform
2) Support for new items on platforms. Now Items, Shapes, lights, particle emitters, and possibly others!
3) Object to object Attachment. Players can now attach Items, shapes, etc to them. Even the attached objects can attach more objects to themselves!
4) Reduced the number of code changes.... a little.


This must be extracted in the base torque directory where it's installed...
c:/torque

or whatever. it's designed to simply overwrite a stock install of torque.

Afterwards you must add pathshape.cc and pathshape.h to your project in visual studio or whatever.

img292.imageshack.us/img292/9507/addexistingxy9.gif

To attach an object, you must use this syntax:

ParentObject.attachChild(ChildObject);

So if you want to attach an item to the player, move the player towards the object, press F11 to get the object ID. Press ~ and type in $player.attachchild(ObjectID);

The item is now attached to the player.

$player.detachchild(ObjectID); is how to remove the object.






Ancient Versions of the code can be found here.
These are version 1.1, not the newest version and probably have bugs that the newer code does not.
Here's a link to the new updated code. It's for torque 1.4...
subvoicestudios.com/~ramensama/torque.zip

And for Torque 1.5
subvoicestudios.com/~ramensama/torque1.5.zip
#201
02/25/2008 (3:27 pm)
I don't mind the node limitation; but is it possible to attach objects to interiors and vehicles?
#202
02/25/2008 (3:32 pm)
Why would you want to attach an object to an interior? But currently due to limitations on how i coded, you can't attach or be attached to interiors. they are derived from scenebase, but i do the mounting call in gamebase... suppose you could rewrite the gamebase attachchild functions to sceneobject, would just have to remove the processafter calls.

You can probably attach the player to vechiles you'll need to add a call to update the child objects to vechile.cc in the processtick. take a look at the differences in player.cc compared to stock. should give you an idea what you'd need to do to attach stuff to vechicles or other shapes.
#203
02/25/2008 (6:09 pm)
I don't want to attach the player to anything, I want other objects to be attached to vehicles or interiors -- items to vehicles, and various interactive objects to interiors. Because of the way my game works, attaching objects to interiors is quite necessary when it comes to map editing, etc.

Anyway, I guess this isn't the resource for me. I'll go look for another one, there has to be something out there.
#204
02/25/2008 (9:59 pm)
Hmmm well there's two issues with attaching objects to interiors. Firstly, comes with the attachment call. I'll add in another call in sceneobject to mimic the one in gamebase. this should allow non-gamebase objects to attach to other objects.

Secondly, is keeping objects attached. currently attachment only occurs when you tell it to do so, and objects cannon't be attached just by loading a mission. This might be able to occur if i add in some more code having it attach to a Named object. I'm sure this is something you'd want right?
#205
02/25/2008 (10:57 pm)
Items can be attached to interiors using 'sticky'.
Look out in item.cpp how sticky process is created and use that idea in another class.
#206
02/26/2008 (7:51 am)
Ramen, that would be wonderful. I was thinking that with the resource I mention below, I would be able to script object attachment upon mission load, but it wouldn't be an elegant solution and would probably also be a pain when mission editing.

I already use that, Picasso. What I'm looking for is item attachment to vehicles. And besides, it doesn't deal with movement -- when an item collides with another object that it can stick to, the item simply ceases to move. You can move the object it stuck to wherever, but the items will stay still.

I found this resource, but whenever I move my interior, I get some very strange transformations from the attached objects. I'll see what I can do about fixing that. If it doesn't work out, I'll just stay patient for your update.

EDIT: Found a fix in the comments and it seems to work quite flawlessly now. Added vehicles to the item's sticky mask, I think my explosives should be able to stick to vehicles now. I wonder if there could be problems with networked games though.

EDIT 2: It seems when I attach explosives to vehicles, they cease to be sticky and try to fall to the ground only to be brought back up to where they're supposed to be. It looks quite odd.

Without attaching they stick just fine, but don't move with the vehicle. I guess I'll wait for your update, Ramen.
#207
02/27/2008 (6:11 am)
Can damage be applied to the platforms? I want to make my platform break in half using debris meshes via an 'explosion'.
#208
02/27/2008 (2:58 pm)
@adam, not sure. The Pathshape is based off shapebase. so if you can do it to a shapebase object, it probaly can be done to the pathshape
#209
03/03/2008 (1:21 pm)
Just asking but would it be possible to use this to attach difs to things like vehicles or characters?
#210
03/03/2008 (1:51 pm)
@Brian read my post - Posted: Feb 25, 2008 23:59

Basically the attachment call occurs in gamebase.cc, interiors are derived from sceneobject.cc. But you could add in a duplicate attachment function in sceneobject. might work that way.
#211
03/10/2008 (4:55 am)
My jerking has been partway solved. Just merged my game with AFX1.1 and most the jerking is gone. If I try to make the pathshape go through a wall, it starts jerking for about 30 seconds, but otherwise it's smooth.
#212
03/13/2008 (1:38 pm)
I just got this working, fantastic! Will have a sample video of my own here soon... :-)

I would really like to see the whole "attachment relative to a node" stuff... I can probably figure out what I'm trying to do with your current code... being able to walk up to an item, play a 'pick up' animation and put the item in your hand, do something with it and have it animated with your body, etc..

Also looking forward to being able to ride on deforming and other animated platforms! :-D
#213
03/13/2008 (2:36 pm)
@ed right, that's exactly what it could be useful for. often in games you see a character pick something up, and it suddently pops into place or something. with this you could precisely control how it moves. if you match your animations, you can pass one item to another player as well.
#214
03/13/2008 (2:53 pm)
I am currently trying to figure that out... using a combination of your child attachment and some of the ideas in this resource to be able to walk up to an item, have the game GUI let you know that you can pick up an item, and pressing the 'pick up' button makes the character reach to pick it up. From there, the item is in a "Holding" state and can be "Used" on another game object, or placed in your backpack (inventory) for future use.

As of now I am able to walk up to an item and have it attach itself off to the side of me (like in your original pics/videos with the health pack). I know I will have to script in the animation to pick it up, but still not sure how to align the item with to hand without having access to the node. It might look fine enough without the node stuff, just thinking down the line.
#215
03/13/2008 (2:57 pm)
Hmm will probably have to rotate the player to face the object perfectly, then perform the animation, making sure you have the proper distance and rotation. OR some real time inverse kinematics...

I'll need a little time to prep the code i have now that allows attachment in relation to nodes, i haven't got the player walking around on animated items, but attachment of static objects to the player nodes is already in place.
#216
03/13/2008 (7:24 pm)
Cool, thats what I'm waiting for.. thinking it will make things much easier for what I'm doing.

Technically they are already facing the shape when they pick it up, since that is kind of a prerequisite of my pick-up system. Really the only sticky thing I'm dealing with is making the player animate to bend down and have the shape attach itself in a way that looks good still when the player gets up and walks around. It all has to do with how well I can get the pick up animation to line up with my world items.
#217
03/25/2008 (2:07 am)
Ill be adding this resource in soon, glad to see the community helping fix and expand Torque.
#218
04/09/2008 (10:46 am)
Tried this out and works great, but I've got a question I didn't see earlier. When the player is detached from the platform, he stops moving completely and drops like a stone, just like jumping off a transport ship in WoW. I haven't had time to try this myself, but what happens if you took the platform's velocity and applied it to the player at the end of detachchild()? I'm assuming it would simulate the player keeping momentum, and they could actually jump up and down on a moving platform without it suddenly speeding off without them.

Or did I screw something up on implementation and keeping the momentum is the default behavior?
#219
04/09/2008 (3:25 pm)
Try this:

Change ConsoleMethod detachChild to this
ConsoleMethod(SceneObject, detachChild, bool, 3, 3, "SceneObject subObject")
{   
    SceneObject * t;       
    if(Sim::findObject(argv[2], t))   {     
		if(t->attachToParent(NULL)) {
			t->setVelocity(t->getVelocity() + object->getVelocity());
			return true;
		}
		else
			return false;
    } else 
        return false;    
}
#220
04/09/2008 (4:57 pm)
That won't work for pathshapes. Pathshapes don't have a velocity. was something i discovered before. but this may work for other objects the player is attached to.