Hello All,
I am new to the community.I think Unity is great and I plan on purchasing it soon. I have experience with Basic, C and a little C++. I am a bit stuck though. I am trying to set up a simple event. I want to click on my unit in this case a box and create a highlight around the the unit. For debugging purposes I just want to create a primitive around the object. (or close for now) the primitive is created when the other primitive is clicked… but how do I move it into place? I appreciate any help you can provide.
var carspeed = 5.0 ;
var turnspeed = 1.0;
var highlight = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
function Update () {
//
if (Input.GetButtonDown("Fire1"))
{
//Screen.showCursor = false;
highlight.transform.position = Vector3(0, 0.5, 0);
}
//transform.Rotate (0,1,0) ;
}
Hey Marvin! Good to see another AI Chicago student roaming around here.
To get the position of the transform use:
var pos:Vector3;
pos = transform.position;
than just set the highlight objects transform to the same values:
transform.position = pos;
Stop by class on Monday if you still need some help. Usual times and usual class room.
Thanks Mike! it works like a charm. It’s good to see some local people on here.
Couple ?'s though.
I’m trying to make sense of this Time vs time or Transform v transform.
I know one is for accessing the component of another game object and one is for the current game object. But which is which?
and when you preform any action is it only in reference to the object the script is attached to?
Generally speaking, class names begin with an uppercase letter and properties/variables begin with a lowercase letter. So, a MonoBehaviour script has a property called “transform”, but this is an instance of the Transform class. There is actually a time property in the Time class, so you often need to write “Time.time” in Unity coding.