AIPlayer walking
by David Horn · in Torque Game Engine · 11/27/2007 (11:59 am) · 6 replies
I'm creating a game that will have a stationary camera. Therefore all of the player.cs 1st person / 3rd person stuff is useless to me. I need absolute player control (i.e. hit left on a joystick or the "a" key makes him move along the x axis). So goal is to use all AI players. Hopefully I can bind the keys to moving a specific AI player to a point in space using the setMoveObject or set Move Destination functions.
Is there any way to make the character walk instead of run?
I 'd love to write a function that, based on the setMoveSpeed, it would automatically be smart enough to switch between running and walking, but I can't find anywhere in the AIPlayer.cc file where it triggers the animations.
Any help would be appreciated.
Is there any way to make the character walk instead of run?
I 'd love to write a function that, based on the setMoveSpeed, it would automatically be smart enough to switch between running and walking, but I can't find anywhere in the AIPlayer.cc file where it triggers the animations.
Any help would be appreciated.
About the author
#2
I always post questions as a last resort. Previous to posting, all I could find relevant was this:
http://www.garagegames.com/mg/forums/result.thread.php?qt=29668
however as you can see from that post, the said problem (which is exactly what I'm asking) was never resolved and I didn't want to bump that old of a topic.
11/27/2007 (5:07 pm)
All do respect, please keep your noob police badge to yourself. That link has nothing to do with my question.I always post questions as a last resort. Previous to posting, all I could find relevant was this:
http://www.garagegames.com/mg/forums/result.thread.php?qt=29668
however as you can see from that post, the said problem (which is exactly what I'm asking) was never resolved and I didn't want to bump that old of a topic.
#3
Regards,
Robert
11/27/2007 (5:49 pm)
What you want to do David, is script a toggle. So make a new key bind toggle some variable true or false by calling some new console function of player class which toggles a bool variable and use the bool in the updateMove function to determine the magnitude of the move. The joystick binds ought to be easy enough for you to figure out.Regards,
Robert
#4
So I would be working from within the player class as opposed to the aiplayer class, correct?
11/27/2007 (6:01 pm)
Yes, the binds I'm not worried about. I'm just trying to change the functionality of the setObjectMove function to produce a walk instead of the default "run"So I would be working from within the player class as opposed to the aiplayer class, correct?
#5
You have some options depending on whether or not you need both walk and run or if you just need walk. If you just need a walk, then you can simply call %obj.setMoveSpeed(0.5); and pass in a smaller value to slow him down and change the run animation so it looks like a walk.
If you need to support both run and walk then what you want to do is programatically change the move speed based on either a key press or the mouse or you could have the guy speed up over time so that he starts out walking and winds up running. You can do this in Player::updateMove() with some timing / state variables.
Then in Player::PickAnimation() or whatever you just choose either walk or run based on the move speed.
If it sounds difficult, then you can take a look at the Horse Pack on the 3D Diggers sight. In that pack, I use the mouse to control the speed of the horse so when you push the mouse forward he goes faster and when you pull back he slows down. The movement goes from a walk, to a trot, to a gallop.
Hope this helps,
Robert
11/28/2007 (1:58 am)
Correct. You'd probably be working with Player.h and Player.cc.You have some options depending on whether or not you need both walk and run or if you just need walk. If you just need a walk, then you can simply call %obj.setMoveSpeed(0.5); and pass in a smaller value to slow him down and change the run animation so it looks like a walk.
If you need to support both run and walk then what you want to do is programatically change the move speed based on either a key press or the mouse or you could have the guy speed up over time so that he starts out walking and winds up running. You can do this in Player::updateMove() with some timing / state variables.
Then in Player::PickAnimation() or whatever you just choose either walk or run based on the move speed.
If it sounds difficult, then you can take a look at the Horse Pack on the 3D Diggers sight. In that pack, I use the mouse to control the speed of the horse so when you push the mouse forward he goes faster and when you pull back he slows down. The movement goes from a walk, to a trot, to a gallop.
Hope this helps,
Robert
#6
11/28/2007 (5:43 am)
Wonderful, thank you.
Torque Owner Maddermadcat
I think that should help you, but if it doesn't, just search again and answer your own question. It's not that hard. =)