I’m making a sort of circular Pong-style game where the player is on the inside of a ring and the enemy paddle is on the outside. I was figuring that I could simply use
to have the paddle follow the “ball”'s motion in a two dimensional plane, but it wasn’t working exactly like that. The paddles go crazy as soon as the ball is launched, spinning wildly around the axis. I have a feeling this is the right track, but considering the ball is moving on x/z, it probably needs to take into account both. There can be multiple paddles. The whole thing needs to stay steady on a two dimensional gameplay plane, ignoring Y.
This makes my camera rotate pretty smoothly about a pivot world point goct.
Called from update function attached to my player. You should be able to achieve the same. I also recommend googling WoW Camera Controls (it has lots of rotation methods) or checking the Controller section of the Wiki Unity script catalogue.
You might want Quaternion.LerpAngle, or take a rotation * Vector(0,0,-radius) and spin the rotation. Or Lerp position, Or Slerp. Or Smoothdamp. Each of these has various benefits you can google.
ddd.x , ddd.y are from Mouse Inputs, so you can substitute for whatever you’re inputting.
Thanks, I'll try that and see how this behaves. Getting this "AI" working should be interesting. I've seen it done in reverse, with the player outside but for gameplay reasons the player is inside.
Okay, no go on that. .y worked, but rotated in wrong direction while it needs to stay on a 2D plane. Substituting .z resulted in the same behaviour as RotateAround, but in more lines of code.
Try this it's simpler than most of the other ones: var angle = Mathf.LerpAngle(...somesortofinputhere); // or set this to something even simpler, directly into the input for less smoothing var radius = 10; var qq = Quaternion.Euler(0,angle ,0); position = qq * Vector3( 0 , 0 , -radius);
Something like this might work. “goTarget” is the game object you want to follow. This will point the forward vector towards the object but will not tilt off the xz plane.
I figured it might be best to display a diagram of what I'm trying to do. Also, I'm working in C# - not Javascript. ![alt text][1] [1]: http://www.teonnyn.com/pictures/diagram.png
Thanks, I'll try that and see how this behaves. Getting this "AI" working should be interesting. I've seen it done in reverse, with the player outside but for gameplay reasons the player is inside.
– DevMerlinOkay, no go on that. .y worked, but rotated in wrong direction while it needs to stay on a 2D plane. Substituting .z resulted in the same behaviour as RotateAround, but in more lines of code.
– DevMerlinTry this it's simpler than most of the other ones: var angle = Mathf.LerpAngle(...somesortofinputhere); // or set this to something even simpler, directly into the input for less smoothing var radius = 10; var qq = Quaternion.Euler(0,angle ,0); position = qq * Vector3( 0 , 0 , -radius);
– gfvfubb