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

Script removing rigidbody component, NOT game object

$
0
0
Hi, I'm creating a simple game, and I can't kill cloned object with rigidbody component. Script just deletes rigidbody component. Here's the code: public class ShooterProt : MonoBehaviour { public Rigidbody projectile; public Transform BarrelEnd; [SerializeField]protected float ShootForce = 2000f; void Update() { if (Input.GetButtonDown("Fire1")) { Shoot(); } } void Shoot() { Rigidbody clone; clone = Instantiate(projectile, BarrelEnd.position, BarrelEnd.rotation) as Rigidbody; clone.AddForce(BarrelEnd.forward * ShootForce); Object.Destroy(clone, 1f); } }

Viewing all articles
Browse latest Browse all 508

Latest Images

Trending Articles



Latest Images

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