Home > Software engineering >  How to do helicopter AI in Unity
How to do helicopter AI in Unity

Time:05-03

I'm a beginner, so I may not understand something. If I made a mistake in something, let me know. I'm making my game on Unity3d and I want to make a helicopter that moves along a given path. When he discovers an enemy, he flies to him and shoots. But I can't make it fly along a given trajectory, I tried to use NavMesh, but it turns over and does not fly in the air. I don't understand how to solve this problem

CodePudding user response:

Try to get Unity training first, there is a similar game and its implementation in one of the tasks on the course.

The course is free and interesting: https://learn.unity.com/ - Junior Programmer Pathway

CodePudding user response:

This is a simple built-in script to move the plane, only forward, backward and rotate, using the built-in function

 float speed = 2.0f; //movement speed
 float rotationSpeed = 60.0f; //rotation speed
 // Update is called once per frame
 void Update()
 {
     // Use up and down arrow keys or W, S keys to control forward and backward
     float translation = Input.GetAxis("Vertical") * speed * Time.deltaTime;
     //Use the left and right arrow keys or A, D keys to control the left and right rotation
     float rotation = Input.GetAxis("Horizontal") * rotationSpeed * Time.deltaTime;

     transform.Translate(0, 0, translation); // move along the Z axis
     transform.Rotate(0, rotation, 0); //rotate around the Y axis
}
  • Related