Game Development Community

Progressive Actions

by Jason Farmer · in Torque Game Engine · 02/09/2006 (3:22 am) · 4 replies

I want the player to turn faster the longer they hold down the turn key
I'd also like the player to move forward faster the longer they hold down the forward key.
Turn speed and Forward movement would of course be capped to a maximum amount.

Sounds easy, and I've done this sort of thing loads of times before in other work.


What I want to know is the *BEST* *TORQUE* way of doing this.

I'm using a player object.

#1
02/14/2006 (4:32 am)
This post is dropping off the bottom of the list...

For clarification..

I want to hold down the left key, and for my player to increase in turning speed.(up to a maximmum) So increasing some sort of turning impulse. Then when the player takes their finger off the Left key, the turning impulse decreases.

Problem is, I don't know where to put this code. Currently there is a turning speed, but not a turning impulse. Also, I don't know how to cause any impulse to be decremented when the player is not turning.. (i.e. holding down the key)

Also, if I do apply some code to the player object to take some turning impulse into account... what happens over the network? Will the impulse be respected somehow by the client and server simulations responsing to the same player actions? Or do I have to take additional measures to ensure the client and server remain synchronised?


Someone must have done something like this.
#2
02/14/2006 (8:30 am)
Player::updateMove

Be warned, there's a buttload of code in there. You'll need to change the way the move's yaw and direction vectors are used to update the velocity, making it accumulate.
#3
02/14/2006 (11:27 am)
The best way is the one that works. :) Manoel's advice sounds good. Unless there's someone out there who's done this exact thing, my advice is to read and understand as much code as you can find in Torque that relates, then give it a try. Your first attempt will probably work OK but not great, and you can refine from there.

That's what I'd do, anyway. :)
#4
02/14/2006 (1:57 pm)
Thanks guys, I've managed to get something working.

First thought was to try to use script. Default.bind.cs has a turn left function which supplies the turn speed to the engine. I thought I could build the accumilating speed in there... No good. Only worked when I hit the left or right key several times. Holding it down did nothing..

So I thought, OK... I'll use triggers.

So I set up 2 triggers. One for the left press, one for the right.

Then in updateMove of the player class, I increment a turn variable, bypassing the yaw value of the moveManager (not sure if this is a good idea, but it's working in a similar way to the jetting resource)

So if the left trigger is active, I decriment my angle, if the right trigger is active, I increment it.
if none are active, I increment or decrement towards zero.

It works, but it's very sensitive (which is why I'm worried about cutting out the move manager, I don't fully understand it but this seems to work)

adding 0.005 to the turn in update move seems to have quite a big impact, so either a tick is a very small amount of time indeed, or update move is running at full pelt on this system and very fast machines will be making something akin to a spinning top when trying to turn a corner.

Does updatemove get called on a tick basis or does it happen in real time and I should temper my turn value accordingly