I’m new to C# and Unity but progressing quickly. I have been able to get most of it under control but this is taking too much time so… I’m throwing up the help Flag
The idea is the player will control a Sphere in a Roller style game via mouse.
Mouse Control: starts with left mouse Press. Records first Point. A GUI helper will appear on that point as visual feedback for input.
Player Drags mouse from start point. Vectors are created on the fly using the angle and distance from the center translates as magnitude (and hopefully speed of the force applied) of the UI drawn vector for imparting that exact vector force on the sphere. The player should be able to command torque from this UI in any direction and most velocities easily and on demand.
So, the trouble comes in a number of ways so far.
The first is: how do I create the corresponding torque in ALL directions? I I have managed to create a prototype that works “half-way” but it wont perform correctly in some quadrants. multipliers were giving me grief in this area as well.
I tried to pull back from the purist approach above and try some alternatives thinking i could run the torque along the X axis like a wheel and just try to “Steer” or rotate it as needed… nope that was a mess.
my code has been altered and tweaked so many times, but I was able to scrape out my original code below.
I apologize now for inefficient or bad coding I’m a designer who likes to dig in…(code)
Initial Code attempt: Drop onto sphere
public class addTorque : MonoBehaviour
private Vector3 spinVector;
float vectValueX = (Input.GetAxis(“Mouse X”)) * spinVector.magnitude;
float vectValueY = (Input.GetAxis(“Mouse Y”)) * spinVector.magnitude;
rigidbody.AddTorque(vectValueX, 0 , vectValueY);
Appreciate any help I can get! I look forward to your replies