using UnityEngine;
using System.Collections;
public class shoot : MonoBehaviour {
public Rigidbody bullet;
public float power = 1500f;
public float moveSpeed = 2f;
Hey bud, you were missing a semi- colon at the end of the class and you had used the type declaration of Transform when you should have been addressing the component which is attached to the gameobject you have this script attached to.
i have rectified the script and all should compile fine now.
This script needs to go on your gameobject.
using UnityEngine;
using System.Collections;
public class Shoot : MonoBehaviour
{
public Rigidbody bullet; public float power = 1500f; public float moveSpeed = 2f;
void Update()
{
float h = Input.GetAxis("Horizontal") * Time.deltaTime * moveSpeed;
float v = Input.GetAxis("Vertical") * Time.deltaTime * moveSpeed;
transform.Translate(h, v, 0);
if (Input.GetButtonUp("Fire1"))
{
Rigidbody instance = Instantiate(bullet, transform.position, transform.rotation) as Rigidbody;
Vector3 fwd = transform.TransformDirection(Vector3.forward);
instance.AddForce(fwd * power);
}
}
}