Turning an object by code over time in custom function
I have AI I want to turn a bit before taking a step in the new direction. I don't want to use update function, is this possible? The AI needs to turn over time.
I am trying a "for" statement in there but still jumps a bit and not smoothly turning like on ice.
I probably won't be of much help here, but I thought I would at least try and see if I can... If I'm reading you correctly, this is a problem I would, personally, solve with animations, but I'm not sure you're going to get something smooth like turning on ice without rotating the 'thing' with the update function. Is there a particular reason why you don't want to use it?
Answer by HenryStrattonFW · Nov 06, 2015 at 05:02 PM
you will need to use some sort of repeating function. If you're set on not using update then you have two main options, Coroutines, or InvokeRepeating.
Coroutines will run each frame until they finish what they have to do but can have various delays depending on how they are yielded. InvokeRepeating will run a method a set number of times, with a set interval between each execution.
Hope this helps point you in the right direction.
Answer by Dibbie · Nov 06, 2015 at 08:15 PM
Using the Update function, would probably be the easiest way... Though you could also use an InvokeRepeating, or a while loop in another function outside of Update, that gets called only once (so you dont have a repeating while loop), and change its rotation a slight bit every time.
Though if you do decide to use Update, you can use a clamp or a slerp, or even a simple Rotate on the object.
Your answer

Follow this Question
Related Questions
Game got slow down On iphone 0 Answers
Can anyone make a timer for me? 0 Answers
How can i make an animation like csgo case opening? 2 Answers
How to make a player move up then forward using ontrigger enter collider? 0 Answers
Smooth aiming script don't work 0 Answers