Player turn rate and seperating mouse turn control
by Demolishun · in Torque Game Engine · 07/01/2006 (11:53 am) · 8 replies
This may require C++, but I want to ask if there is a way to control the turn rate of the player object? Also, is there a simple way to disable mouse control for turning?
Here is what I am planning to do for a vehicle based upon the player object:
1. Disable side to side motion. Easy to do.
2. Control the turn rate of the player. A bit harder, no support in the datablock that I can find.
3. Use mouse to control a turret either mounted on the player or through a seperate animation. If animation probably have to change C++ code.
4. Make it so the reticle can aim on an object without the object turning. Track where turret is pointing. Probably needs C++ code.
It sounds like I need to make a copy of the player object and make a new object tweaked for my needs.
Thanks
Here is what I am planning to do for a vehicle based upon the player object:
1. Disable side to side motion. Easy to do.
2. Control the turn rate of the player. A bit harder, no support in the datablock that I can find.
3. Use mouse to control a turret either mounted on the player or through a seperate animation. If animation probably have to change C++ code.
4. Make it so the reticle can aim on an object without the object turning. Track where turret is pointing. Probably needs C++ code.
It sounds like I need to make a copy of the player object and make a new object tweaked for my needs.
Thanks
About the author
I love programming, I love programming things that go click, whirr, boom. For organized T3D Links visit: http://demolishun.com/?page_id=67
#2
Thanks for the info.
07/01/2006 (1:24 pm)
Are you thinking I can benefit from fixes/changes to the player class if I subclass it? I am not sure I see the advantage of subclassing. Thanks for the info.
#3
say you think of a new feature which you want in both regular old Player and in FranksPlayer,
unless you subclass you'll have to implement it twice.
ditto say a new feature or bugfix from the community.
if there's a real reason *not* to subclass, then by all means,
but in general you're ahead whenever you avoid duplicating code.
07/01/2006 (1:27 pm)
It just keeps your code cleaner.say you think of a new feature which you want in both regular old Player and in FranksPlayer,
unless you subclass you'll have to implement it twice.
ditto say a new feature or bugfix from the community.
if there's a real reason *not* to subclass, then by all means,
but in general you're ahead whenever you avoid duplicating code.
#4
07/01/2006 (2:19 pm)
Doesn't the Tank Pack have it's class setup so you rotate the tank turret with the mouse while driving and steering with the keyboard? I'm guessing it's probably somewhat similair to what they do here, where you add a third rotation value to the move struct, and have the mouse control that value for twisting a part of the player while binding the keyboard to the old yaw values to turn the player.
#5
Unless I find a reason not to subclass it makes sense as you said.
Paul,
Thanks for the link. That should help.
07/01/2006 (3:22 pm)
Orion,Unless I find a reason not to subclass it makes sense as you said.
Paul,
Thanks for the link. That should help.
#6
If I subclass my new player class on player and since AIPlayer is based upon player, then it should work to control my subclassed player? If I remember my C++ right it should work on anything based upon player?
Thanks,
Frank
07/03/2006 (5:22 pm)
Orion,If I subclass my new player class on player and since AIPlayer is based upon player, then it should work to control my subclassed player? If I remember my C++ right it should work on anything based upon player?
Thanks,
Frank
#7
i'm not totally sure what you're asking, can you rephrase ?
if you want to use the functionality of AIPlayer (eg walk-to) in your new class,
you should make AIPlayer the parent of your new class.
eg, the uh lineage would be Player --> AIPlayer --> FranksPlayer
watch out for the possibility that AIPlayer has overridden/changed some of the stock Player functionality, tho.
i think there's one or two normal player functions which are changed in AIPlayer.
ooor,
i guess you could insert your new player class in between Player and AIPlayer.
that would be fine too. possibly better, if you want to give new functionality to AIPlayer.
the lineage there would be like Player --> FranksPlayer --> AIPlayer.
also,
Paul's advice re the tank pack is pretty good. If they've already solved it, then woo hoo!
07/04/2006 (12:41 am)
Hi Frank -i'm not totally sure what you're asking, can you rephrase ?
if you want to use the functionality of AIPlayer (eg walk-to) in your new class,
you should make AIPlayer the parent of your new class.
eg, the uh lineage would be Player --> AIPlayer --> FranksPlayer
watch out for the possibility that AIPlayer has overridden/changed some of the stock Player functionality, tho.
i think there's one or two normal player functions which are changed in AIPlayer.
ooor,
i guess you could insert your new player class in between Player and AIPlayer.
that would be fine too. possibly better, if you want to give new functionality to AIPlayer.
the lineage there would be like Player --> FranksPlayer --> AIPlayer.
also,
Paul's advice re the tank pack is pretty good. If they've already solved it, then woo hoo!
#8
This is what happens when you are trying to write code and yell at your kids to keep quiet at the same time.
I think with all the potential issues and the fact that player is very proven I am going to duplicate it verbatim as a new player with parallel inheritance from shapebase. I have looked at the resources to make turret changes and they range from adding a rotation that uses the look animations to dividing up the move in processtick. Both will alter the default player too much. I still want the default player as is. The inheritance just seems messy especially if I still want the ai stuff. AIplayer is not that big either. To get the same functionality I would just add a copy and inherit from my version of player. Pretty easy.
07/04/2006 (1:11 am)
Oh man. I was thinking the opposite of what inheritance gives you. Methods for player will work on anything derived from player. The new methods of the classes derived from player will only work on those classes. If I want that functionality I need to base my object on aiplayer. Doh! This is what happens when you are trying to write code and yell at your kids to keep quiet at the same time.
I think with all the potential issues and the fact that player is very proven I am going to duplicate it verbatim as a new player with parallel inheritance from shapebase. I have looked at the resources to make turret changes and they range from adding a rotation that uses the look animations to dividing up the move in processtick. Both will alter the default player too much. I still want the default player as is. The inheritance just seems messy especially if I still want the ai stuff. AIplayer is not that big either. To get the same functionality I would just add a copy and inherit from my version of player. Pretty easy.
Associate Orion Elenzil
Real Life Plus
$Pref::Input::KeyboardTurnSpeed is the client-side preference value you're looking for.
it's 0.05 by default.
As for rerouting mouse to control a different thing than keyboard, that sounds a bit more difficult.
The place to start hunting is probably in the method "yaw()" in default.bind.cs.
Possibly you could define a client as having two sets of controls instead of one,
and send the state of both of them up to the server. - which would definitely be C++.
If by "make a copy of the player object" you mean actually copy the file and tweak it,
i think you'll be better of just making a subclass ?