Game Dev: How to shoot
The 2nd part of this series, the 1st part is located here
https://youtu.be/ZiCMUGOE2k0
The only big mistake is I did not add the Firepoint.position into the first run which I corrected later in the video
Down below is the code however youtube does not like brackets
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Shooting : MonoBehaviour
{
public Transform Firepoint;
public GameObject BulletPrefab;
public float bulletForce = 10f;
// Update is called once per frame
void Update()
{
if (Input.GetButtonDown("Fire1"))
{
Shoot();
}
}
void Shoot()
{
GameObject Bullet = Instantiate(BulletPrefab, Firepoint.position, Quaternion.identity);
Rigidbody2D rb = Bullet.GetComponent (bracket go here) Rigidbody2D(bracket go here) ();
rb.AddForce(FirePoint.right * bulletForce, ForceMode2D.Impulse);
}
Other Videos By RunningRobert
2021-05-11 | Monolight (Free Steam Puzzle game) |
2021-05-03 | Ardelyx ARDX Delay Summary 03May2021 |
2021-05-02 | Children of Silentown Prologue |
2021-04-29 | Protalix Biotherapeutics PLX Post CRL Summary 29Apr2021 |
2021-04-26 | The Longest Road on Earth Demo |
2021-04-23 | Ardelyx ARDX Pre PDUFA Summary 23Apr2021 |
2021-04-20 | Utopia |
2021-04-18 | Game Dev Enemies |
2021-04-16 | Fortress Biotech FBIO and Avenue Therapeutics ATXI NDA Delay Summary 16Apr2021 |
2021-04-14 | The Final Station The Only Traitor DLC |
2021-04-11 | Game Dev: How to shoot |
2021-04-09 | Trevena TRVN Summary 09Apr2021 |
2021-04-06 | Friendly Fire (Free Steam Game, Ludum Dare Game) |
2021-04-04 | Making A Simple Game Part 1 - Simple Movement Script |
2021-04-01 | Protalix Biotherapeutics PLX Quarterly Report and Pre PDUFA Summary 01Apr2021 |
2021-03-30 | Mini Countries |
2021-03-28 | Dorfromantik |
2021-03-26 | Catalyst Pharmaceutical CPRX Summary for 26Mar2021 |
2021-03-23 | Tadpoles Tales (Free Steam Game, Award Winning) |
2021-03-21 | Sizeable Game |
2021-03-14 | Curse of the Dead Gods |