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 🙂
#Set players position issue
1 messages · Page 1 of 1 (latest)
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.
If I disable it, would that un reference it in other scripts?
why would it?
Disable != destroy.
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
Well yeah. (Some) Find methods can't find disabled objects.
But you should not ever use find anyways.
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.
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.
(Except findobjectbytag! We benchmarked this one a year or two its ok, and quite fast actually)