Continuos player movement
by Andy S. · in Torque 3D Professional · 12/08/2011 (1:06 pm) · 5 replies
Hi,
is there a way to have the player moving continusely? Want I want to have is the following. Player is steered left/right using a nd d keys. He cannot go backwards. Mouse will not turn him. THere is no sidestepping, he only can turn. And the player moves continusely forward. Any hints?
is there a way to have the player moving continusely? Want I want to have is the following. Player is steered left/right using a nd d keys. He cannot go backwards. Mouse will not turn him. THere is no sidestepping, he only can turn. And the player moves continusely forward. Any hints?
#2
12/08/2011 (3:23 pm)
Setup a boolean variable to be tested in the key's function. You should be able to then kill the key command by setting the boolean to the appropriate value.
#3
function moveForwardContinuously(%val, %interval) {
moveForward(%val);
$Movement::schedule = schedule(%interval, 0, "moveForwardContinuously", %val);
}
to cancel it, call this method
function cancelForward() {
cancel($Movement::schedule);
}
obviously this would only work for forward movements, but you get the point. Just make some global boolean vars like kerry said.
Hope this helps, its my first post here!
Jeff
12/08/2011 (3:57 pm)
heres a quick little method in torquescript, should serve the purpose for what you want:function moveForwardContinuously(%val, %interval) {
moveForward(%val);
$Movement::schedule = schedule(%interval, 0, "moveForwardContinuously", %val);
}
to cancel it, call this method
function cancelForward() {
cancel($Movement::schedule);
}
obviously this would only work for forward movements, but you get the point. Just make some global boolean vars like kerry said.
Hope this helps, its my first post here!
Jeff
#4
12/09/2011 (2:45 pm)
Thanks guys for the help. Jeff, I tried your function. BUt it did not really work...the player starts moving, but then gets slower and somehow gets stuck. What I did is just put the function in, creatd a keybind for it (to start the moving), and set the %interval to 500). Any other ideas, or what am I doing wrong?
#5
Try it and let me know what it does.
Jeff
12/10/2011 (8:33 am)
hmm, i am sorry if it slows down, i am used to marble blast gold's torque game engine, which of course you know its an old engine. Maybe I am missing something, I don't know. maybe set the value at say 3 and the interval at 50 milliseconds, it would make it loop faster and maybe reverse that effect.Try it and let me know what it does.
Jeff
Associate Steve Acaster
[YorkshireRifles.com]