- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
Nirvana33 · Feb 23, 2013 at 05:51 PM ·
gameobjecttransform
Convert Transform to Gameobject
using UnityEngine; using System.Collections;
public class example : MonoBehaviour {
public GameObject a;
public Transform b;
void OnMouseEnter(){
b=a;
}
Error is : error CS0029: Cannot implicitly convert type UnityEngine.GameObject' to
UnityEngine.Transform'
what can i do?
Comment
Best Answer
Answer by poday · Feb 23, 2013 at 06:02 PM
Every GameObject has a Transform and every Transform has a GameObject. The Easiest thing to do would be to have:
void OnMouseEnter(){
b=a.transform;
}
Your answer
Follow this Question
Related Questions
Instantiate rigidbody, transform or gameobject? 1 Answer
I want to move a cube with rotation but I find this problem 1 Answer
How to keep a Gameobject in the same position after a transform.Rotate? 2 Answers
Is there any way to convert Collision to a Gameobject or Transform? 1 Answer
Difference between Vector3, Transform and GameObject 2 Answers