Game Development Community

Stoping Movement (when doing a action)

by Minesh · in Torque Game Engine · 08/07/2009 (3:47 pm) · 3 replies

I was working on afireball and i though of making stop the clients motion but itdont work anyadvice?
function FireballImage::onCharge(%this, %obj, %slot)
{
%obj.ChargeFire = new ParticleEmitterNode(Chargefire) {
position = %obj.getTransform();
rotation = "1 0 0 0";
scale = "1 1 1";
dataBlock = "bombParticleEmitterNode";
emitter = "FireballChargedEmitter";
velocity = "1.0";
};
%obj.Burned = new ParticleEmitterNode(Burned) {
position = %obj.getTransform();
rotation = "1 0 0 0";
scale = "1 1 1";
dataBlock = "bombParticleEmitterNode";
emitter = "FlameburnEmitter";
velocity = "1.0";
};
%obj.client.player.maxForwardSpeed = 0;
%obj.client.player.maxBackwardWalkSpeed = 0;
%obj.playthread(1, armreadyboth);
}

function FireballImage::onAbortCharge(%this, %obj, %slot)
{
%obj.dead = true;
%obj.schedule(0, explode);
Schedule(0,0,"Burnfire",%client,%obj);
%obj.playthread(2, SpearReady);
%obj.playthread(2, root);
%obj.client.player.maxForwardSpeed = 7;
%obj.client.player.maxBackwardWalkSpeed = 6;
}

#1
08/07/2009 (9:02 pm)
First thing - using code tags makes it easier for us to help you :)

%obj.client.player.maxForwardSpeed = 0;
%obj.client.player.maxBackwardWalkSpeed = 0;
Here you're trying to stop the player from moving by changing maxForwardSpeed and maxBackwardWalkSpeed. There are two problems with this.

1. %obj.client.player is a Player object, but those values you're trying to change actually belong to PlayerData, not Player. So the script has no idea what you mean, since it can't find those members in the Player object.

2. You're trying to change datablock values. This is a terrible idea. Datablocks are supposed to remain static for the entire dureation of a mission - and what's more, they affect every object that uses them. So imagine you have ten players in your level using the same datablock (because they're all humans). If you change the maxForwardSpeed of the datablock they're using, then they all use this new speed. Not the effect you want.

Since you haven't licenced the engine, you'll be restricted to using script. That's tough, since there's no inbuilt ability for Players to alter their maximum speeds. I suggest you use a method like this:

When a Player is hit by a fireball, message their client telling them 'freeze'. Look up commandToClient for this. When the client receives this message, they set the global variable $PlayerFrozen to true. In your movement commands in default.bind, have a look for the functions that allow the player to move. Make the contents of these functions conditional upon $PlayerFrozen being false - so movement commands only get sent when we're not frozen.
#2
08/08/2009 (2:43 am)
I get it.
So if when a player is hitdirectly by a fireball it will process thecommand commandToClient (got to find the ormake Freeze command and then after a short timeit un freezes. Thanks alot :D
Oh and well i dont own the engine but i use a game whichhas the f11 editor and stuff.
#3
08/08/2009 (10:09 pm)
Yes, the editors and scripts can all be used without licencing the engine. You can accomplish a lot that way. Good luck!

Oh yeah - and to make it unfreeze after a little while, I'd look at the schedule function. DO this on the server, and schedule another commandToClient that tells the client to unfreeze.