Quantcast
Channel: Questions in topic: "clone"
Viewing all articles
Browse latest Browse all 508

Make a projectile teleport to the player instead of cloning. (2d)

$
0
0
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

Viewing all articles
Browse latest Browse all 508

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>