var rightSpeed = -0.01;
var leftSpeed = 0.01; // Same as rightSpeed but a negative
var forwardSpeed = -0.01;
var backwardSpeed = 0.01;
// from +Z perspective
function Update()
{
if(Input.GetKey(“left”))
{
// transform.RotateAround(transfor.eulerAngles = Vector3(-10,0,0), leftSpeed);
transform.RotateAround(transform.forward, leftSpeed);
// transform.eulerAngles = Vector3(0,0,6)
I’ve been making a marble game board, and I’m trying to make the board only rotate so far, so that I don’t have the marble fall off the board, I’ve tried looking up ways to limit rotation, but none what I have found seems to work for me.
I was thinking of trying to set a euler angle as a maximum value of rotation, but I can’t seem to get that to work.
I like how this line of code works;
transform.RotateAround(transform.forward, leftSpeed);
but I’d like it to not rotate the board 360 I’d like it to rotate till its at 7 degrees and stop.
I have simply included the part of the code for the “left key”, but I have all four, up, down, left, right; keys working.
If possible, I’d like to use a Euler angle as a limit, and rotate smoothly to that limit.