I need a tween or rotate function that doesn’t have a “hitch.” Essentially when the player uses turn left or turn right it should rotate that direction 90 degrees. As it is right now, what happens is kind of random. If you use the left turn, and just left, it will do it correctly 4 times and then it will rotate to the right 270 degrees on the 5 press.
If you use the right turn, It will do it correctly 3 times and then do the 270 left turn on the fourth try.
That is just for using one or the other, if you try and go back and forth and randomly do left and right turn it will work sometimes and sometimes it will 270 degree in the opposite direction.
What I need is consistent 90 degree left or right turns that take 1 second to tween or rotate. Whichever function works.
That was actually what I tried first. For turning left it will work once and then just stops completely. I believe right turn it works twice and then stops completely.
This solution posted above does make all the turns, just with the occasional 270 counter rotation glitch.
Whoops. So, what I did before was try and use -90 and +90. I didn’t subtract or add from current tank angle. When I did that, surprise, surprise, it totally works!
I love playing around with concepts. I also love minimal code.
I started using an object variable named TargetAngle to the tank. The premise is to increase or decrease the variable. Then calculate the tween time based on the difference between the current angle and the target.
Um, this is awesome. This is where I want to end up. I’ve just started a couple of weeks ago but I want to get to where I approach these problems just like this.
I appreciate the code and thoughtfulness of it. Definitely learned something from this.
There should be a pencil next to your topic name, you can edit it there. Unfortunately, since you are new to the forums, you might not see the pencil there. All good if it isn’t there, it’s just a way to help other members of the forum know it’s solved.