Im looking for how to make an Cube attack me when it sees me, ive tryed everything but nothing helps, please leave a step by step tutorial on how to do it, and the scrips i have to use! Thanks!
You don’t learn to create scripts by asking people to write scripts for you.
But this is what you could do if you want to make a cube ‘attack’ you (there may be a better way):
First we need to get the cube to look at the player. In Unity, there is a function for that in transform:http://docs.unity3d.com/Documentation/ScriptReference/Transform.LookAt.html
Now that we are looking at the player, move forward. You could use transform.Translate to do that.
The player needs to have health. We can create a variable called health.
Now we check whether the cube is close enough to attack. We can check this in an if statement with Vector3.Distance (transform.position, player.position). Note that you have to create a transform variable then fill it with the player.
If we are close enough, remove the player’s health (health -= 1) and don’t move forward.
If we aren’t, keep moving forward.
Now that you have the idea, all you need to do is put it in code.