I want to make a visible slider on screen that turns a canons tip from 0-90 degrees and depending on the angle it’s set to, add that as the direction in which the projectile is shot with RigidBody.AddForce. Does anybody know how to achieve this in C#?
inside the event set the proper local rotation value of the cannon tip game object by the value you got from the slider
then when you fire the cannon just read the global rotation of the object and add impulse force and multiply it with some thrust value you want after you spawned the projectile at the tip of the barrel (or reused it from some object pool or something)
Some code would be nice for this : “inside the event set the proper local rotation value of the cannon tip game object by the value you got from the slider”
You can find countless tutorials on UnityEvents, Slider value changes, rotation or even combined (I think this one is doing exactly what you’re looking for):