Hello, I need help with spawning a cube at the “gun” object, I got it working with fixed coordinates but do nowt know how to do it with something that moves, this is the error I get now:
Cannot implicitly convert type UnityEngine.GameObject' to
UnityEngine.Vector3’
using System;
using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;
public class Shoot : MonoBehaviour {
public int m_Ammo;
private Vector3 gun = GameObject.Find("Gun");
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (CrossPlatformInputManager.GetButtonDown("Fire1") && m_Ammo >= 1)
{
GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube.AddComponent<Rigidbody>();
cube.transform.position = new Vector3(gun);
}
}