How can I briefly immobilize a player?
by Ean Huddleston · in Torque Game Engine · 10/22/2006 (12:23 pm) · 15 replies
Any ideas on what the easiest way to briefly immobilize a player might be? I'm creating a transporter (using starter.fps) and want my player to be briefly immobilized (for ~2 seconds) after he's been transported to the new location.
Thanks!
Thanks!
#2
moveMap.pop();
moveMap.schedule(2000, push);
Presuming that you are using the moveMap for your ActionMap,
this will remove your keybindings and turn them back on in 2 seconds (2000 ms)
10/22/2006 (2:55 pm)
Easiest way is to do:moveMap.pop();
moveMap.schedule(2000, push);
Presuming that you are using the moveMap for your ActionMap,
this will remove your keybindings and turn them back on in 2 seconds (2000 ms)
#3
put it in your OnEnterTrigger for your trigger's datablock.
So you may have something like this:
This is good enough for single player since you are getting started. If you go with multi-player, you would have to get the client of the colliding object and send the client a message so that the right person gets his input suspended. But this is more than you are asking at this moment, so I'll stop there.
10/22/2006 (3:54 pm)
Since we are in the 'Getting Started' forum, I suppose I should have mentioned where to put that snippet.put it in your OnEnterTrigger for your trigger's datablock.
So you may have something like this:
datablock TriggerData(TPTrigger)
{
tickPeriodMS = 100;// default value
};
function TPTrigger::OnEnterTrigger(%thisDatablock, %thisInstance, %collidedObj)
{
moveMap.pop();
moveMap.schedule(2000, push);
}This is good enough for single player since you are getting started. If you go with multi-player, you would have to get the client of the colliding object and send the client a message so that the right person gets his input suspended. But this is more than you are asking at this moment, so I'll stop there.
#4
Ean
10/22/2006 (4:55 pm)
@Jeremy - Thanks for the detailed example. That seems to be doing the trick.Ean
#5
Is there a way to make the pop command effective immediately, regardless of whether I'm holding down a movement key?
Thanks!
10/22/2006 (6:17 pm)
One more quick question about this. I noticed that moveMap.pop is effective immediately only when I stop directional intput to the player. If, for example, I'm running forward when I enter the transporter, and keep my finger on the run forward key even after being transported, I keep running forward until I take my finger off the key. The pop command then becomes effective, freezing up the player for 2 seconds.Is there a way to make the pop command effective immediately, regardless of whether I'm holding down a movement key?
Thanks!
#6
that is something I forgot. While a previously mapped control is in action, it will remain in action until the player does something else (like your running forward issue).
Try putting:
$mvForwardAction=0;
right after you pop the moveMap.
$mvForwardAction is set to the forward speed when you press the controlling key and it is set to 0 when you let it up.
10/22/2006 (8:05 pm)
Ean,that is something I forgot. While a previously mapped control is in action, it will remain in action until the player does something else (like your running forward issue).
Try putting:
$mvForwardAction=0;
right after you pop the moveMap.
$mvForwardAction is set to the forward speed when you press the controlling key and it is set to 0 when you let it up.
#7
i might have the name wrong on $mvBackwardAction. edit: nope, that's right.
10/22/2006 (8:30 pm)
I think you may want to do the same for $mvBackwardAction, $mvLeftAction and $mvRight action as well.i might have the name wrong on $mvBackwardAction. edit: nope, that's right.
#8
to stop jumping and shooting as well.
10/22/2006 (9:45 pm)
And perhaps $mvTriggerCount0 through $mvTriggerCount2to stop jumping and shooting as well.
#9
10/22/2006 (10:12 pm)
Works perfectly now. Thanks!
#10
10/23/2006 (1:41 am)
That will not work in multiplayer though.
#11
10/23/2006 (5:04 am)
Fair point, but we concluded early on that he would have to send a message to the client of the colliding player to handle a multi-player scenario, and these steps would then be all be wrapped up in that (4th post ^^).
#12
10/23/2006 (6:08 am)
Which is still bad for multiplayer as the client can just chose not to immobilize :) But whatever works for your type of game. I just would not want cheats in mine.
#13
The better, server-side solution would be more complex tho, and i'd put off implementing it until you're actually going multiplayer.
10/23/2006 (8:44 am)
Stefan is pointing out that this method is "trusting" the client to not move. ie, it would be simple to make a client-side hack which simply disabled this feature.The better, server-side solution would be more complex tho, and i'd put off implementing it until you're actually going multiplayer.
#14
10/23/2006 (12:56 pm)
I understand and appreciate this feedback, but I'm taking into consideration that we are in a "Getting Started" forum and that someone asking questions here may not be ready to make engine code changes nor may they even be concerned about hacks.
#15
10/23/2006 (4:01 pm)
Yep, I truly am just "getting started." But I appreciate the info and caveats.
Torque Owner Stefan Lundmark