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
#41
04/05/2007 (8:10 pm)
Cool, we fixed it. Thanks.
#42
04/08/2007 (4:19 pm)
I am new compiling. I have gotten other resources to work on TGE 1.5. This one I got 327 errors. All point to the same problem. This one below. I am using the new TGE 1.5.1.

static LightInfo           smAmbientLight;

more specific error. I dont list them all to many:)
c:\Documents and Settings\owner\Desktop\test_sdk\TGE_1_5_1\engine\sim\sceneObject.h(665): error C2501: 'SceneObject::LightingInfo::smAmbientLight' : missing storage-class or type specifiers

any simple advice would be wonderful.
#43
04/08/2007 (4:21 pm)
I've not had time to check with 1.5.1 does it work with 1.5?
#44
04/08/2007 (4:23 pm)
I dont think I have a copy around. I will look for an older 1.5 right now. ThanX for the quick response.
#45
04/08/2007 (5:10 pm)
Would this be easy to impliment into TGEA Ramen?
#46
04/08/2007 (5:27 pm)
Probably not. Maybe you could do it with winmerge. I don't have TGEA, so i can't find out.
#47
04/17/2007 (6:25 pm)
I got it to compile to TGEA. Only 1 problem, the player slides off the platform when its starts moving. That is a problem. :P What would be the problem to that.
#48
04/25/2007 (4:32 pm)
I have a bit of a question for the mod author, but first, a comment on using this in TGEA: Works fine for me. Just used WinMerge, which is the same way I put it into my heavily-modded TGE. Adam, just comb through WinMerge again; it's likely you missed a line someplace, probably the one which actually attaches the player to the platform.

Anyway, on to the question. I've been attempting to do one of 2 things; either one will be fine for my purposes: I either want to get the player to ride directly on vehicles as if they were pathshapes, or simply mount a pathshape to a vehicle and have the player ride that. I realize that this won't work 100%, as the player only rotates on the Z axis, but for my purposes this is sufficient.

To this end, I first attempted to add basic mount functionality for the pathshape; this worked fine, however once I'd done it, the player would no longer stick to the shape (though it would successfully attach). I then attempted to modify the vehicle class to update the position of its attached children, just as the pathshape does, and altered player to attach to vehicles under it instead of pathshapes. Once again, attachment was successful, but the player did not move with the vehicle.

Right, well, the question ends up being: Exactly what does an object, doesn't matter what type, need to do to update its position to the child (in this case, the player)? I see a good bit of stuff going on in processTick, specifically the loop which actually updates the children, however this doesn't seem to be enough to get the job done. What am I missing here?
#49
04/25/2007 (4:45 pm)
Alright, hopefully i can explain things a bit. I tried to make as few code changes as needed.


UpdateXformChange(OldTransform);
recursiveChildUpdate(mLastXform);

are added at the end of the process tick for the player.

the first function modifies a sceneobject variable called mLastXform.
it's basically a matrix... the difference between the last process tick.

the second is pretty simple

void ShapeBase::recursiveChildUpdate(const MatrixF offset){
    for (U32 i=0; i < getNumChildren(); i++) {
			//ShapeBase* cur = static_cast<ShapeBase*>(mGraph.firstChild);
		ShapeBase *o = static_cast<ShapeBase*>(getChild(i));
		o->updateParentedTransform(offset);
    }
}

it should update the child objects transform based on the parent's new transform.
the real magic happens on the updateparentedtransform. It takes the known offset of the parental relations and modifies the transform based on that.

This is important cause the vechicle functions should include this at the end of it's process tick.

If it is called, then perhaps you're not attaching it right...? How are you doing this?

Also. i wouldn't suggest attaching the pathshape to the vehicle... I'd work with making the vehicle do what you need.
#50
04/25/2007 (6:09 pm)
First, thanks for the quick reply (not to mention the original resource).

I just did this on a "clean" copy to test it (by clean, I mean only this resource installed):

I went into vehicle.cc and added the following at the end of the processTick function (I'll explain why this is different from what you posted in just a second):

UpdateXformChange(getTransform());
for (U32 i=0; i < getNumChildren(); i++) {
			//ShapeBase* cur = static_cast<ShapeBase*>(mGraph.firstChild);
		ShapeBase *o = static_cast<ShapeBase*>(getChild(i));
		o->updateParentedTransform();
}

First, since this is a vehicle, I had to rely on the fact that I could pull out the current position with getTransform (there's no transform matrix available inside processTick). Second, the function you show doesn't exist in the resource; the pathShape's interpolateTick uses this same code, but not by calling a function. Third, in the resource, updateParentedTransform doesn't take any parameters. I'm assume you might be working with a slightly more updated version of your code.

At this point, hoping I've done the right thing, I go into the player's updateAttachment function and change PathShapeObjecType to VehicleObjectType (on two lines).

Now, when I go into a test environment (totally flat), pop a vehicle in, and stand on it, the console reports that I've been mounted ("I'm on ####", "Object is ####"). Moving the vehicle, however, does not move the player (also tried applying impulse to the vehicle, to make sure this wasn't just failing when moving it in editor). Strangely enough, the player appears to move for just one tick when I move the vehicle, then snaps back to its original position.
#51
04/25/2007 (6:13 pm)
It's true. my version is "in the works" adding some additional functionality. Tell you what, i'll experment later tonight and see if i can get done what you are looking for. No guarantees, i may oversleep a bit :)
#52
04/25/2007 (6:13 pm)
Hello Henry,

A quick question. Would you be able to send me the changed files for TGEA for this resource. I tryed for 3 hours yesterday and gave up. It would be really helpfull if you could.

Email:cbeer1@cogeco.ca

Thank you.
#53
04/25/2007 (6:35 pm)
Hey, any help at all is great. I appreciate you taking an interest in this in the first place.

I'll mess around with it a bit myself, but I'm not expecting too much; I can't say I'm an expert in matrix math (never got the original child-parent resource some of this is based on to even interpolate children).

I should note that I ran a test with completely clean TGE, and the bounce effect I noted above with the player on top of the vehicle seems to have nothing to do with this resource; apparently this just happens when a player is on top of a vehicle in stock Torque. I also confirmed that the Player is remaining attached to the Vehicle; I added an extra console message for the "didn't find anything under the Player" case in updateAttachment, which only appears once I actually jump off the vehicle or move it really violently. The actual attachment of player to vehicle would probably need to be altered from the way it works with the pathShape, but that's a whole different (and much simpler) issue; it works well enough to test.
#54
04/25/2007 (6:36 pm)
Alright, i'm messing with the code now, but i don't know how to spawn vehicles....
so unless you help me, i'll search about on how to add a vehicle to the starter mission
#55
04/25/2007 (6:37 pm)
Adam: I'm sorry, but the version of TGEA I merged this into already contains my entire set of changes from my TGE project (I'm in the process of slowly converting entirely to TGEA). Even if I sent you the edited files, they wouldn't work with stock TGEA.
#56
04/25/2007 (6:39 pm)
You'll have to steal the car.cs file from starter.racing\server\scripts and exec it in your game.cs, as well as taking the entire starter.racing\data\shapes\buggy directory. If you do just that, mounting vehicles won't actually be enabled, so you can stand on it without worrying about sitting in it. The "defaultCar" should show up in the creator under shapes->vehicles.
#57
04/25/2007 (7:56 pm)
Ok, i figured out how to add the car. I also got the vehicle to be the parent of the player object.
However. there's going to be some issues beyond my current control.

There's a bit of... collision going on between the car and the player.... so it seems to stumle sometimes while moving the player on it.

subvoicestudios.com/~ramensama/vehicle.cc

let me know how that works.

This will require you to specify the vehicle in the updateattachment function like you already have.

i set the player on the car, then set the car as the control object.... seems to work.
#58
04/25/2007 (9:23 pm)
W00t! Do people still say w00t?..

Ah, I see, you did the UpdateXformChange in each of the setPosition functions and the child update in processTick. Just tried it out, works exactly as I wanted; I expected to have some issues with the vehicle hitting the player, and can solve that.

I already intended to redo vehicle vs. player collision so that vehicles do not stop when hitting a player, and instead move the player. For the moment, I'm just going to disable vehicle->player collisions to play around with this (player->vehicle will still be active, so you can stand on the vehicle).

Once again, thanks for the quick help. I didn't expect to get this solved today just by posting a question here. I've actually been trying to get this working since I started my project over a year ago.

Going to take a moment right now and set up a mock-up aircraft carrier, try running a couple players around on it over LAN and see what happens.
#59
04/25/2007 (9:29 pm)
Yeah, let me know how that works out.

placement of the UpdateXformChange needs to occur before a change in transform. You gotta feed it the "transform to be"

from there it generates a new mLastXform, which the child object uses to determine how much it needs to adjust its position.

mat.mul(getParent()->mLastXform,getTransform());
		setTransform(mat);

basically, it "adds" it's current transform with how much the parent moved in the last tick.
#60
04/26/2007 (12:03 pm)
Did anyone get this to work with TGE 1.5.1 yet ?
thanks!