Game Development Community

Moving Platform Collision Detection

by Jason Davis · in Torque Game Engine · 05/23/2006 (3:31 pm) · 138 replies

Okay, I've searched the forums to no avail. I have a dts object scripted to move upward when the player steps onto it (via a scripted trigger.) The dts object is a simple cube. Even though the player detects the collision mesh when stepping onto the cube and the cube begins to visibally rise, the player continues to stand where the old collision mesh was. I have tried everything I know to do... anyone have any help or resources they can give me? Thank you so much and I will look forward to a response.
#101
06/30/2006 (3:38 pm)
@Bad Guy
It's not exactly a matter of the player needing to be processed after. The way this works now is...


When the player is not moving, but the platform is. The player doesn't have a move, so there will be no "predicted" movement path. so just setting a transform will, of course, not interpolate it's movement between ticks.

If I disable player movement, i can easily remove the interpolation issues by syncing there transform and render transforms using a set offset. But that removes the ability for the player to actually move independantly from the platform.

There are a couple issues with trying to sync transforms and render transforms. and i believe some of it to be the fact it can call either function multiple times during a process tick or an interpolate tick. So i can't just put all my fixes in those functions, i've got to find a way to make it all magically work.

But, i did set it up to use processafter :) Doesn't seem to make a change :(


But now i'm trying something a little different. Let's imagine the same situation. You have a moving platform, and you have a player object.

I started trying this last night. When a moving object's cycle starts.... it calcuates the difference between the last frames transform, and the current.

void SceneObject::UpdateXformChange(const MatrixF &mat){

	MatrixF oldxform = getRenderTransform();
	oldxform.affineInverse();
	mLastXform.mul(oldxform,mat);
	Point3F old;
	mLastXform.getColumn(3,&old);
	//Con::printf("Pre %f %f %f", old.x, old.y, old.z);

}

Results in a variable mLastXform which should have the difference between the frames. Now we need to take this xform and apply it to our player object that's "attached"

MatrixF m;
	   m.mul(mat,getParent()->mLastXform);

and make m our new transform for the player.

I think part of the issue is determining the right place to insert that code. can't do it in settranform, or rendertransform, so i'm gonna try a few things like forcing the platform object to update both of them. If the platform is processed before, then when the player object is processed it should be able to still have all it's own movement objects available to it. however theres no checking done for collision or other stuff when the platform updates the positions for it.

Damn, that's a long post. :/

@Casey, i'll try to clean up my files and i'll post a link to them here later.
#102
06/30/2006 (4:32 pm)
Ok,
well it was just a thought anyhow :)

my next thought is this,

currently with mountables (player on vehicle)
this seems to be the exact same scenario.
can we not just implement the same logic here?
like there must be a piece missing to implement the results we are looking for as vehicles do it.
this reminds me of the jerkiness you had when lagging in tribes 2 while watching someone fly/drive something away.

so we are talking about a delta value and two transformations to interpolate between. right?
so in vehicle the storage and usage is all laid out already.

I realize what your saying with relation to player movement.
so does this mean it works fine 100% when the player does not move?

have you got this as a patch or a diff or anything?
I can prolly take sometime this weekend if you had a way to apply this to a clean checkout
I would be interested in taking a stab with you at it.

Edit:
sorry I did not really respond, here that is.

without having the code ready to go its hard to say exactly anything about you plan.
except that this should be applied slowly overtime via interpolateTick no? is that what you have?
#103
06/30/2006 (4:46 pm)
Well, what i meant by it's fine when the player isn't alowed to move is...

If i prevent the player from updating it's transform, and simply set one based on the relation to the parent object. it doesn't jitter. There should be some links to some movies above that show this off. As i stated, i'll clean up the code and post it here a bit later.
#104
06/30/2006 (9:05 pm)
Ok Ramen i'll be looking forward to it... im setting up windows on my desktop now that i have new hard drives so hopefully i'll get a chance to start trolling the code.... seems like to me that all that needs to be done is take the velocity from the transform vector of the platform and add it to the transform vector of the player ... i think the problem is getting it from local object space vectors to world space vectors...

maybe im just repeating what you've already done though ~_-
#105
06/30/2006 (9:08 pm)
I actually attempted a form of velocity transfer. BUT you gotta ask if that velocity inheritence will affect the animations? like if the player is on a platform, and it inherits that velocity.. will it start playing an animation?
#106
06/30/2006 (9:17 pm)
Which animation?
fall?

that one is based on contact to ground last time I checked.
jump? again findcontact handles the skip logic for animations.

I am sure you would be fine, and that velocity would be correct no?
like the super fast elevator :)

umm... are we using findcontact and collision to handle movement? or just parent linkage?
I assume all the collision code is in place and you are mounting the platform based on feedback from the detection, is it safe to say you are disabling player collision to the platform?
#107
06/30/2006 (9:19 pm)
Heh- ouch.

from what i've seen of the velocity-to-animation code, it absolutely will start playing an animation.

i think one will have to introduce a notion of "container" into the player* object and take the container's velocity into account in the player's velocity-to-animation routine.

let's just hope you don't have a steerable elevator which you can steer into an even larger [steerable] elevator !

* player, shapebase, gamebase, whatever.

edit: @badguy - all the animations such as run forward, backward, strafe, fall, etc, are based off of the player's velocity. so i think if you had a platform carrying the player sideways, the player would start to play the strafe animation.
#108
06/30/2006 (9:24 pm)
Ahhh really?
well..
I think I would Ax That! :)

are you sure it is not based on the MoveInfo or whatever the move struct is called?

I have not looked in a long time, I will take your word for it.

oh yea, and how come I found this:
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=10167

is this not what we are here talking about?
#109
06/30/2006 (9:28 pm)
Yah,
i think the MoveInfo stuff is what tells the engine how to map the player's velocity to a given animation.
eg, "forward = 0, 1, 0", "right = 1, 0, 0" etc. it then decides which animation is the best fit with the current velocity.

but the velocity is still relative to the world, not a container such as a moving platform.


and.. yeah, the pathed interiors resource.
i'm also pretty curious how this thread fits with that.
#110
06/30/2006 (9:34 pm)
Well this "thread" is different. I actually posted a link to that pathed interior resource in this thread.

This is allowing dyncamic parenting and movement on any type of simobject. though, i'm currently working on the more complex aspect of it now. i've already been able to attach objects to players or other objects.

the way it works is a parent/child relation ship. when the parent object moves, it updates the children objects transforms. like just picture a table, now lets stack some stuff on the table. now move the table. what happens in torque normally? well the table moves, the stuff on it does not.

Now you could do an ObjectMount(), but that's very limited. you have to attach via nodes and junk. This will allow you to put an object wherever you want, and attach it to an object.
#111
06/30/2006 (9:56 pm)
Ok I see.

would you not just want to slip into the node system?
as it is working pretty tight.

are you networking this?

like other than generating an offset to make a node what other limitiations are there?

in any event, I think the right place to do this logic, is via the same route that it is currently being done.
seem's you have covered alot of ground and only need to finalize the math usage.
Code will help to get this solved. But I am sure you will crack it any second now :)


Good work!
#112
06/30/2006 (9:58 pm)
The stuff Ramen is working on sounds pretty exciting IMO. there are numerous applications to this if a stable implementation can be reached. when it's done, yes it could be used as a player platform, but the fact that it's a parent/child relationship where the child is free to move means it could even be used as a world node. this could be extended to allow for things such as moving spaceship interiors, submarine interiors, or maybe even spherical planets. sounds very cool if you guys can get it working.
#113
06/30/2006 (10:44 pm)
ramensama.dyndns.org:8000/temp/working.avi
Pretty much says it all.
#114
07/01/2006 (1:07 am)
Hmmm...

Question:
Lets say that the player is in an elevator, its going up, and the player decides to jump, what happens?

From what I can gather, it seems that the player wouldnt beable to jump because their tranform is gettin changed to that of the elevator...

?
#115
07/01/2006 (8:31 am)
Well as it is now, when the player jumps, the player does infact jump. But the players position is still being modified by the platform. so when they jump strait up, the land in the same spot they jumped from. But one of my next steps is going to be automating the attaching process, so that the player is attached to whatever they are touching with their feet, so when the player jumps on a horizontally moving object, whenever the player is no longer in contact with it.... their transform is no longer modified, so they could jump strait up and off the platform.
#116
07/01/2006 (8:57 am)
Impressive video. can the platform move at say running speed ?
#117
07/01/2006 (9:04 am)
Yep. looks good even when the pathshape's speed is 20.
#118
07/01/2006 (9:11 am)
I know that I'm coming late to the discussion, but have you thought about making the platform simply affect the player's position, instead of assigning it?

With proper interpolation (and actual physics) implementation, especially coordinate space manipulation, you should be able to have the player simply take the platform's position into account (or vice versa) when calculating it's own physics.
#119
07/01/2006 (9:25 am)
Well stephen, i'm not quite sure i understand what you mean by "affect"
How it's basically working is when the platform moves, it then sends the move command to the player object to update it's position based on how much the platform moved in it's tick. then when the player's turn is up. it's position is in sync with the platform.

When it comes to client side, it's a similiar situation. The platform moves, then the player's turn come up.
(This is the most difficult part for me)

Right now, the player does it's whole interpolatetick, and at the end, it's render transform is modified with the difference between the platform's transform, and it's rendertransform.
I'd like to do the updating at the begining of the players tick. but that'd probably require modifying the players transform. How it is now is innacuurate when it comes down to the players visible collision. since the render transform may be updated and put the player partially thru a wall they would't normally be able to do.
But i'm imagining this would only be an issue if the platform was at very high speeds.

I'm cleaning up this code right now, I'll create a new thread in the Private SDK Forums with the needed code changes, and post a link to it here.
#120
07/01/2006 (9:56 am)
Good job Ramen... you will truly be a hero if you could get this to be complete. I am eagerly awaiting your results!