ERROR CS0029: Cannot implicitly convert type `UnityEngine.GameObject' to `TriggerSphere'
Hello
I have this error (11,39): error CS0029: Cannot implicitly convert type UnityEngine.GameObject' to
TriggerSphere' but I don't found how to fix in this code
using UnityEngine;
using System.Collections;
public class Character : MonoBehaviour {
public TriggerSphere ts;
private bool isJumping = false;
private GameObject moveToward;
void Update() {
if( isJumping && Input.GetKeyDown(KeyCode.A) && moveToward == null ) {
TriggerSphere tsClone = Instantiate( ts, transform.position, Quaternion.identity ) as GameObject;
tsClone.character = gameObject;
}
if( moveToward != null ) {
/* Note : B */
}
}
void OnCollisionEnter( Collision collision ) {
if( collision.gameObject.CompareTag("CanHit") ) {
isJumping = false;
/* Note : C */
}
}
void SetBounceTarget( GameObject go ) {
moveToward = go;
}
}
Thank you
Comment
Best Answer
Answer by Positive7 · Sep 05, 2015 at 12:40 PM
GameObject tsClone = Instantiate(ts, transform.position, Quaternion.identity) as GameObject;
Now I have this error : error CS1061: Type UnityEngine.GameObject' does not contain a definition for
character' and no extension method character' of type
UnityEngine.GameObject' could be found (are you missing a using directive or an assembly reference?)
I have replaced gameobject by TriggerSphere and now it is correct.