I’m following this tutorial to make a simple FPS except I do the code in C#.
It says to instantiate a missile (rigid body sphere) I need to associate the Missile prefab with projectile variable and when the code is in JS it can be done by dragging and dropping since I see all the information about the script in the Inspector section. When it’s C# Inspector only shows that my script is attached to the Launcher, no variables and all.
How do I associate Missile prefab with projectile variable?
Just in case, here’s my code:
using UnityEngine;
using System.Collections;
public class MissileLauncher : MonoBehaviour {
Rigidbody projectile;
int speed= 20;
void Update (){
if(Input.GetButtonDown("Fire1"))
{ Rigidbody instantiatedProjectile=(Rigidbody)Instantiate
(projectile,transform.position,transform.rotation);
instantiatedProjectile.velocity=transform.TransformDirection(new Vector3(0,0,speed));
Physics.IgnoreCollision(instantiatedProjectile.collider,transform.root.collider);
}
}
}
Thanks so much!
– spaceb0t