Object.transform.position is not working in hdrp

Hi! I am newbie in Unity, and I am trying to use object.transform.position, but it made object moving randomly.

public GameObject Light;
public GameObject Scenesetting01;
public GameObject Scenesetting02;
public GameObject Player;
// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{

}

public void Morning()
{
Scenesetting01.SetActive(true);
Scenesetting02.SetActive(false);
Light.SetActive(false);
}

public void Night()
{
Scenesetting01.SetActive(false);
Scenesetting02.SetActive(true);
Light.SetActive(true);
}

public void MoveToInterior()
{
Player.transform.position = new Vector3(-39, 10, 10);
Player.transform.rotation = Quaternion.Euler(0, 180, 0);
}

Here’s what I used for transform.position and rotaiton.

After I applied this, the player moved to the point where I did not set.

Please help me.

Thank you!

First, use code tags .

Second, as far as I can tell that code wouldn’t move anything at all. Your MoveToInterior function (and all your other functions) aren’t being called anywhere, unless they’re being linked from somewhere else (like a UI button).

Do you have any errors in the console? Are there other scripts that might be moving the object? What position is the object actually being moved to? (A screenshot would be ideal for the last one as that can reveal other issues as well)

Thank you so much for your reply!

4888805--472409--캡처.PNG
My character is supposed to move to the red way, but when I clicked the button in blue spot, it made me moving toward black way.

If you do not mind, could you provide me some examples of transform :(?

Thank you!

A screenshot of the editor window (including the Inspector and Hierarchy windows, with the moved object selected) would be more helpful in figuring out the problem.


This is a snap before I clicked the button with the script that I attached.

This is a snap when I clicked the button. I was supposed to move opposite way.

Thank you!

Is the object you’re moving a child of something else? If so, then “transform.position” (which refers to the world space position) won’t look the same as what you see in the inspector. Maybe try transform.localPosition instead?

Hi! Thank you for replying, I reply back too late due to time difference.

What do you mean localposition?

I am trying to move OVR playercontroller. It is not a child of something else.

I tried to re-write “position” as a localPosition, but it is not working as well :frowning: