Hi everyone!
I took a helicopter for an obstacle and want it to ‘patrol’ the territory. For that, at the extreme points of its path I want it to:
Stop.
Rotate by 180 degrees (not instantly - i want the rotation speed be a serialize field).
Start moving in the opposite direction.
My best result was that I made this copter flounce like mad (compared current position to the certain values and if it exceeded them the object just instantly turns 180).
Can you help me with this please?
Since your idea is rather complex, it’s probably the best to use an animation to have the helicopter patrol, stop, rotate and continue to patrol. Animations are covered in this course.
If you want to do that via code, you could start with defining when the helicopter is supposed to stop. Then make it stop. You know if-statements and our extreme values are 0 and 1. Use Debug.Logs to see what’s going on during runtime because it is relatively unlikely that we reach exactly 0 and exactly 1.
Well, it’s a bit too complex for an earlier section in a course catering to beginners. However, if you are willing to challenge yourself, you could try to solve this problem via code. The difficult part is to define the conditions. The code itself is rather simple because you know everything you need (if-statements, the relevant methods, etc.).
Animating is fairly easy if you already animated something in Unity. You could watch a little tutorial on Youtube.
Or you could write your idea down, proceed with the course and try to realise your idea at a later juncture. The helicopter definitely a nice and manageable idea.