good guys, first deskulpe traduçao the bad, I am Brazilian and to using the google translator. but anyway I am not good at programming but would like to know how to script and how to apply it. the case is for a space game where the aim of the cannons would be centered in the middle of the screen and the ship would have mov free scenario with the keyboard controls. what I’m getting is that the same result:
I thank anyone who can help, right now.
A realistic space game is pretty easy to do; all you need is Input.GetAxis and Rigidbody.AddForce / AddForceAtPosition.
If you have written a script and you have a problem with what it is doing, then you should ask on Unity Answers, posting your properly formated script for us to look at. If you are just asking someone here to teach you how to program assuming no knowledge; no, go read some C# for beginners reference material. Or if you are asking someone here to program the game for you so you don’t have to learn; again no.
I often tell Unity beginners to start with making something like Asteroids so you’re starting in the right place- but, unless you take the time and effort to go look up everything you need to figure it out yourself, there is no point.
Hello to you in Brazil. Google translator did a pretty good job. I hope it does as well going the other direction.
What you are asking for is code to solve multiple technical problems. This is not what UA is all about. We help you solve individual technical issues so you can write your own code. The script for the ship movement in the video is fairly sophisticated. Here is a simple script you attach to the camera to get you started:
#pragma strict
var speed = 75.0;
function Update() {
var v3 = Vector3(Input.GetAxis("Vertical"), Input.GetAxis("Horizontal"), 0.0);
transform.Rotate(v3 * speed * Time.deltaTime);
}
As for shooting, there are a huge number of posts on UA. Google for combinations of ‘unity3d’, ‘shoot’, ‘projectile’, ‘bullet’, ‘raycast’, ‘spawn point’. The one tricky part of your problem is that the bullet is aimed from the center of the screen, but it is shot from someplace else. To make this happen, you can raycast to find the position in 3D space hit, then you can use a Transform.LookAt() on the spawn point to aim the bullet in the correct direction.
You can download the book, “Unity 3 Game Development Hotshot” with the scripts codes. to make your airplane shoot, just investigate and change the player with the airplane. It also teaches a lot of helpful stuff to start programming.
This asset looks right along these lines, its super smooth and also fully commented so you could check that out - worked as a great base for my space game, then I built it up from there adding guns, etc.