I'm trying to make a 2d platformed. In it the player can shoot a projectile. I've been following a tutorial where they make it so the bullet makes a clone of itself. I want it so the bullet can teleport to the player and move (so that only 1 can be on screen at a time.) Here's the code I have so far, how do I change it to make it work?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerAttack : MonoBehaviour
{
public Transform firePosition;
public GameObject projectile;
// Update is called once per frame
void Update()
{
if (Input.GetButton("Fire1"))
{
Instantiate(projectile, firePosition.position, firePosition.rotation);
}
}
}
here's the video for context
https://www.youtube.com/watch?v=uKWbNWPAZq4&t=336s
↧