GetMuzzleVector returns inverted solution when player upside dow
by Demolishun · in Torque Game Engine · 07/29/2006 (11:59 am) · 5 replies
I have a player object mounted upside down to a another object. I have set up the control of the mouse to be transferred from the other object to the player in the processtick function. This allows me to control the other object as the primary object and use the player object as a turret.
Everything is working very well, except one problem. When I fire a weapon from the turret (player) object the aim is inverted. I point the turret down and it shoots up, when I point the turret up it shoots down. I followed the console function responsible, getMuzzleVector, to the function getCorrectedAim in the file shapeImage.cc. I believe this is where the solution gets inverted due to assumptions made about the eye vector always being oriented one way. Since my turret (player) is mounted upside down it fires in the opposite Z angle of where the muzzle is actually facing.
Has anyone dug through this to change this behavior? I eventually want to have the cursor in first person view point at an enemy and perform eye corrections for aim, but it needs to work at any angle depending on how the turret is mounted.
Everything is working very well, except one problem. When I fire a weapon from the turret (player) object the aim is inverted. I point the turret down and it shoots up, when I point the turret up it shoots down. I followed the console function responsible, getMuzzleVector, to the function getCorrectedAim in the file shapeImage.cc. I believe this is where the solution gets inverted due to assumptions made about the eye vector always being oriented one way. Since my turret (player) is mounted upside down it fires in the opposite Z angle of where the muzzle is actually facing.
Has anyone dug through this to change this behavior? I eventually want to have the cursor in first person view point at an enemy and perform eye corrections for aim, but it needs to work at any angle depending on how the turret is mounted.
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
We modified the playerclass to act like a space-vessel, and in that case we had to enable rotation around the X axis. This exposed the very problem you're talking about. I cannot remember how we solved it, but it was a hack involving the use of mHead (eventho we did not use the animation of head - in the end, we kept it to keep control of the transform/renderTransform).
Sorry I cant be of more help. Good luck.
Edit: To solve this you would have to take a look at updateMove and unpackUpdate, I think the co-sinus math should be a good start. It basically checks at what angle you're looking and limits the view. My math aint very strong though so I hacked away.
Should be easy to spot.
07/30/2006 (1:29 pm)
I think Paul's on to something.We modified the playerclass to act like a space-vessel, and in that case we had to enable rotation around the X axis. This exposed the very problem you're talking about. I cannot remember how we solved it, but it was a hack involving the use of mHead (eventho we did not use the animation of head - in the end, we kept it to keep control of the transform/renderTransform).
Sorry I cant be of more help. Good luck.
Edit: To solve this you would have to take a look at updateMove and unpackUpdate, I think the co-sinus math should be a good start. It basically checks at what angle you're looking and limits the view. My math aint very strong though so I hacked away.
Should be easy to spot.
#3
Thanks, if I decide to re-pursue the inversion issue I will check out what you said.
07/30/2006 (3:27 pm)
I was having trouble pinning it down so I am trying to mount the turret right side up, but it will look like it is mounted upside down. So far it is working except it is shooting the host object right now. Need to figure out how to keep it from shooting what it is mounted to now.Thanks, if I decide to re-pursue the inversion issue I will check out what you said.
#4
07/31/2006 (10:15 am)
Either define the object you are mounted to as sourceObject when you create the projectile in script (that value is used for a collision timeout to keep it from colliding with what fired it), or if that makes it hit the turret instead, just add a second sourceObject value (sourceMountedObject or something) that is uses the collision timeout as well.
#5
I just added check to see if this is a turret. If it is then it does the above. If not then it does the above with this change:
Works like a charm.
Thanks Paul.
Now I need to figure out how to get my crosshair to move in the view screen and make sure it shoots where your aiming.
07/31/2006 (7:24 pm)
It did the trick:// Create the projectile object
%p = new (%this.projectileType)() {
dataBlock = %projectile;
initialVelocity = %muzzleVelocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj.getObjectMount(); // this was changed
sourceSlot = %slot;
client = %obj.client;
};I just added check to see if this is a turret. If it is then it does the above. If not then it does the above with this change:
sourceObject = %obj;
Works like a charm.
Thanks Paul.
Now I need to figure out how to get my crosshair to move in the view screen and make sure it shoots where your aiming.
Torque Owner Paul /*Wedge*/ DElia
[edit]
Errr yes... I mean only the z-rotation data is updated and you would need to update the x and y rotation as well.
[/edit]