Hi,I’m or I was,I don’t know a javascript scripter,but I think nice to use c#,I learned c# syntax faster but I’m having many problems to use it with unity.That’s my problem:
I got a code that create a ball when F1 is pressed:
In C#:
using UnityEngine;
using System.Collections;
public class Shot : MonoBehaviour {
public GameObject bola;
void Update () {
if(Input.GetKeyDown("F1"))
{
GameObject ball=GameObject.Instantiate(bola);
}
}
}
But this code doesn’t works.That’s the error message:
Cannot implicitly convert type `UnityEngine.Object' to `UnityEngine.GameObject'. An explicit conversion exists (are you missing a cast?)
I translate it to js:
var bola:GameObject;
function Update () {
if(Input.GetButtonDown("F1"))
{
var ball=Instantiate(bola,transform.position,transform.rotation);
}
}
And works,but c# with the same things fails:(