Continued: Moving the player along a straight line
by Michael K. · in Torque Game Engine · 05/09/2007 (11:17 pm) · 13 replies
This thread continues from http://www.garagegames.com/mg/forums/result.thread.php?qt=61901
@Orion Elenzil
Thank you for your help offer.
The player should accually be able to jump, walk forwards and backwards.
I basically want him to be able to do everything just like in a 3d world but hooked on one straight line (axis).
Thanks again.
@Orion Elenzil
Thank you for your help offer.
The player should accually be able to jump, walk forwards and backwards.
I basically want him to be able to do everything just like in a 3d world but hooked on one straight line (axis).
Thanks again.
#2
05/11/2007 (8:39 am)
Unbind strafing and left/right mouse turning?
#3
My thought was simply to go into Player::processTick() and somewhere in there set the player's Z component to zero. Then if that seems to be the effect you're looking for, you could get fancier and add code to let you turn it on & off, etc. I'll try to look into it a bit more today.
05/11/2007 (8:44 am)
Doh, Michael, sorry i forgot to get back to you on this.My thought was simply to go into Player::processTick() and somewhere in there set the player's Z component to zero. Then if that seems to be the effect you're looking for, you could get fancier and add code to let you turn it on & off, etc. I'll try to look into it a bit more today.
#4
i did that, but i'm trying to get the player to stick on that line even if he, for example, gets hit by an explosion.
05/11/2007 (8:46 am)
Hi Benj,i did that, but i'm trying to get the player to stick on that line even if he, for example, gets hit by an explosion.
#5
Thank you. I'll see if i can find anything in player::processTick()
05/11/2007 (8:49 am)
@orion elenzilThank you. I'll see if i can find anything in player::processTick()
#6
okay.
the code change below will restrict all players to the XZ plane.
that is, they can move along X and Z, but not Y.
this is based on TGE 1.3, but should be good for 1.5 or whatever.
i'd recommend trying this out and deciding if it's really what you want,
and if so changing it so that it's a bit more general.
for example constraining each player to an arbitrary plane per-player,
making it toggle-able from script, etc.
player.cc
in Player::updatePos(),
find these lines:
and insert this right in front of them:
05/11/2007 (11:07 am)
Michael -okay.
the code change below will restrict all players to the XZ plane.
that is, they can move along X and Z, but not Y.
this is based on TGE 1.3, but should be good for 1.5 or whatever.
i'd recommend trying this out and deciding if it's really what you want,
and if so changing it so that it's a bit more general.
for example constraining each player to an arbitrary plane per-player,
making it toggle-able from script, etc.
player.cc
in Player::updatePos(),
find these lines:
// Set new position
// If on the client, calc delta for backstepping
if (isClientObject())
{
delta.pos = start;
delta.posVec = delta.posVec - delta.pos;
delta.dt = 1;
}and insert this right in front of them:
// constrain to XZ plane start.y = 0.0f;
#7
05/11/2007 (11:16 am)
Oops. the correct location of that code is Player::updatePos(), not Player::interpolateTick().
#9
05/11/2007 (11:46 am)
No prob!
#10
I just tried it out a while and noticed that the player quite often falls through the terrain (while walking up hills for example). What could be the cause of this?
05/11/2007 (12:33 pm)
@Orion ElenzilI just tried it out a while and noticed that the player quite often falls through the terrain (while walking up hills for example). What could be the cause of this?
#11
but i guess it's possible that this might be more involved than adding one line.
i tested it out briefly on DIFs and DTS objects and it seemed okay with those.
unfortunately i don't have time to look at it in more detail.
05/11/2007 (1:28 pm)
That's a little surprising,but i guess it's possible that this might be more involved than adding one line.
i tested it out briefly on DIFs and DTS objects and it seemed okay with those.
unfortunately i don't have time to look at it in more detail.
#12
Make the platform smaller than the foot of the player model, with no texture.
If the platform is small enough and the player is bound to it, the player should simply be able to spin in place as the platform moves along its path.
05/11/2007 (4:06 pm)
Why not permanently attach the player to a pathed interior? Make the platform smaller than the foot of the player model, with no texture.
If the platform is small enough and the player is bound to it, the player should simply be able to spin in place as the platform moves along its path.
#13
and i would expect the player to fall thru the ground (or possibly any surface)
if that surface is tilted along Y.
that is, if the normal to the surface has any Y component in it.
i wouldn't expect it if the surface were say flat.
one workaround might be to enforce the player to be above the terrain like this:
.. note this code is untested (i haven't even compiled it), so something may not work.
it's based on the source for the ConsoleFunction getTerrainHeight().
edit: oops, originally had pos as a Point3F, it should be Point2F.
05/11/2007 (4:51 pm)
Michael - i thought about it a bit more,and i would expect the player to fall thru the ground (or possibly any surface)
if that surface is tilted along Y.
that is, if the normal to the surface has any Y component in it.
i wouldn't expect it if the surface were say flat.
one workaround might be to enforce the player to be above the terrain like this:
start.y = 0.0f;
if (isServerObject())
{
TerrainBlock * terrain = dynamic_cast<TerrainBlock*>(Sim::findObject("Terrain"));
if(terrain)
{
F32 terrainHeight;
Point2F pos;
pos.x = start.x;
pos.y = start.y;
Point3F offset;
terrain->getTransform().getColumn(3, &offset);
pos -= Point2F(offset.x, offset.y);
terrain->getHeight(pos, &terrainHeight);
start.z = getMax(start.z, terrainHeight);
}
}.. note this code is untested (i haven't even compiled it), so something may not work.
it's based on the source for the ConsoleFunction getTerrainHeight().
edit: oops, originally had pos as a Point3F, it should be Point2F.
Torque 3D Owner Michael K.