Simple Shooting | 2D | Bullets | Unity Game Engine

preview_player
Показать описание
Copy code from here-

Feel free to Like and Share to show support for this channel.
Don't forget to leave a comment if anything comes to mind.
Have a nice day :)

#unity #csharp #tutorial
Рекомендации по теме
Комментарии
Автор

The best example i found. i really learn to much with this. thank you!

hectormzt
Автор

anyway got mine
so i declare two empty object named left and right and i base on character movement so in update i put this the one empty object i manually rotate Y into 180 "left one"

//bullet
public Transform bulletSpawnPointRight;
public Transform bulletSpawnPointLeft;
public GameObject bulletPrefab;
public float bulletSpeed = 10;

void Update()
{

if ((horizontalMove <= -.1f)&&
{

Invoke("shooteft", 1f);

}
if ((horizontalMove >= .1f)&&
{

Invoke("shootright", 1f);
}

void shootleft()
{

var bullet = Instantiate(bulletPrefab, bulletSpawnPointRight.position,
= bulletSpawnPointRight.right * bulletSpeed;
Debug.Log("throwleft");
}
void shootright()
{


var bullet = Instantiate(bulletPrefab, bulletSpawnPointLeft.position,
= bulletSpawnPointLeft.right * bulletSpeed;
Debug.Log("throwleft");
}
}

leonedandrewTumbaga
Автор

Thanks to you and to this tutorial I understood how to shoot bullet🙂

MikaelL
Автор

thank you very much and One Big Like ;)

YubisSmileStudio
Автор

i used this but instead of up i use right, now my problem is left

leonedandrewTumbaga
Автор

For some reason this didn’t work the code had no errors I did everything right, but what I have to shoot with SpaceBar? What do I have to shoot with?

Jay-ovqo