#why doesnt it let me drag the transform

1 messages · Page 1 of 1 (latest)

hollow fable
#

@lament wagon you reading this?

lament wagon
#

what

hollow fable
#

just started a thread to not flood the channel with our conversation

lament wagon
#

ok

hollow fable
#

so there are several ways you can go about doing what you want to do (if i understand you correctly)

#

first: try to avoid using public. If you want to have the same field in the inspector as you achieved with public, use:

[SerializeField] GameObject Ts;
lament wagon
#

yes

#

Copied still doesnt let me drag it in

hollow fable
#

yy, w8

lament wagon
#

k

hollow fable
#

next: You can drag stuff manually like you tried, but if your script is always attached to the same type of gameobject, it's better to get the Components you need via code, just like i showed you earlier:

lament wagon
#

ok

hollow fable
#
Transform gameObjectTransform
Void Start()
{
gameObjectTransform = GetComponent<Transform>();
}
#

this stuff

lament wagon
#

But it doesnt let me drag it#

hollow fable
#

ok, next: You defined Ts as a Gameobject, so you have to drag the entire Gameobject from the Hirarchy on the left side into your field. That should work

lament wagon
#

Now I have the player in ts

#

But I want the transform to be there

hollow fable
#

sweet. Now that you have the player in Ts you can do ts.transform and do all the transform stuff you want to do from there

lament wagon
#

Ok

hollow fable
#

If you only want to access transform it's better to change the Gameobject to a Transform, get the transform via GetComponent<>() and work from there.

lament wagon
#

ok

hollow fable
#

This saves you from writing "transform" everytime you want to do something and is a bit cleaner since your script cant accidentally access other components.