PlayMaker Help & Tips > PlayMaker Help

Using the mouse to roll something in a direction.

(1/1)

Lane:
What should I use to translate mouse input (towards any direction) into a rotation vector for an object?

This would be in a 3rd person perspective for a character and I want be able to move the mouse to the left and then have the whole object tilt to the left +/- on that axis, or if the mouse is moved forward I want the object to tilt forward +/- on that axis. I'll also clamp this at 6 degrees max so it doesnt tilt all crazy upside down or in some unintentional way.

All this vector and math float from inputs stuff is confusing me... I've always just used pick's and look at's for rotating but I need to use the physics engine for this one and its all different.

Lane:
Well it looks like I'm making some progress. I have thrust and roll working. Yaw/Pitch pending...

W and S speed up and slow down the rotor/thrust
A and D roll left and right

http://dl.dropbox.com/u/38606641/Heli/Heli.html

For Thrust I'm just adding force on self Y for the basic "speed", so if you roll the rotor in the right direction then it will be thrusting right. The actual commands are just subtracting or adding to a ActualForce value that is constantly being applied to the helicopter. I don't like adding it per frame so I want to find a better way to lerp this smoothly and regardless of framerate.

For Roll I'm setting a get key down start state and when either A or D are pressed it flips to either adding or subtracting from the roll torque value. Positive values go one way, negatives apply it the other direction. Pretty simple.

Now the tricky part I'm doing now is trying to use mouse vectors based on screen position to adjust pitch and yaw. I don't know how to get a mouse point on the screen relative to the center and convert that to a value that I can throw at the torque modifier to apply pitch and yaw. I don't want to use keyboard controls for the pitch and yaw so that points me toward the mouse vector conversion thing.

Either way, I like where it's heading and I have some good ideas to apply.

Originally I wanted to use ONLY the mouse to roll the hull into a direction, then only WASD would be necessary for Yaw and Thrust Speed but I can't figure out the vector stuff to do that, maybe I can add it in a different control system experiment.

Lane:
Updated the Dropbox webplayer.

The lack of rotational constraints is making it insanely hard to control within reason.

W/S control the amount of force applied to Y
A/D control the torque applied to roll left and right

The mouse pointer is getting the screen position and doing some math to make a usable number that can be used to apply torque on the pitch to aim higher/lower and to turn left/right. So in order to be stable you have to keep the mouse on the red dot that is on the rotor blade center. It's really hard to control.

I might decide to use the mouse for only pitch(vertical aim) and use Q/E for roll, then A/D for yaw (turning). If not then I need to find a way to constrain the rotation of the chopper so it stops when it gets to a certain angle and keeps a little more stable for the player.

Navigation

[0] Message Index

Go to full version