#Set players position issue

1 messages · Page 1 of 1 (latest)

sturdy meteor
#

I made a player that moves with a character controller (move method). I also made a function, that when it gets called should set the players position to 0,0,0.
I made it like that:
player.position = …
I referenced to the player as a Transform.
But when the function gets called, the players transform doesn’t change.
Thank y’all for any help 🙂

tacit nacelle
#

Character controllers override any other position changes.
If you want to move your object without the CC, you need to disable it, reposition the object, and enable it again.

sturdy meteor
#

If I disable it, would that un reference it in other scripts?

tacit nacelle
#

why would it?
Disable != destroy.

sturdy meteor
#

Ok

#

I just though of it because I had issius with a script not being able to reference a deactivated gameobject

#

of not being able to find deactivated ganeobjects

tacit nacelle
#

Well yeah. (Some) Find methods can't find disabled objects.
But you should not ever use find anyways.

sturdy meteor
#

Yes

#

I already learned about that

#

but for most of my scripts I am too tired to change things or set up a gamemanager

#

It’s just to much

#

when I just use it in the start method, it shouldn’t be that much of a lagging machine right?

#

Only more loading time.

tacit nacelle
#

Technically yes.
But find calls are also a code design and structural issue.
You cannot be sure that Find will return a specific value, if you hapoen to have multiple objects that match your search criteria.
And "I'm too lazy" should not be an argument for a production project.

strong spear