I am trying to say if the Y of my player reaches below 0 change the players position to 0,1,0 it wont work thought and I tried using Vector3 but it says I cant use Vector3 like a method Please help!
Here is my code If your wondering I'm making a 3D game about a player dodging blocks.
using UnityEngine;
public class RSet : MonoBehaviour
{
public GameObject player = null;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if(player.transform.player.y < 0) {
player.transform.position = Vector3(0,1,0);
}
}
}
,This is my code...
using UnityEngine;
public class RSet : MonoBehaviour
{
public GameObject player = null;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if(player.transform.player.y < 0) {
player.transform.position = Vector3(0,1,0);
}
}
}
Answer by Larry-Dietz · Dec 06, 2019 at 10:52 PM
Make the following change, and see if it works as you are expecting...
change
player.transform.position = Vector3(0,1,0);
to
player.transform.position = new Vector3(0,1,0);
Hope this helps, -Larry
THAN$$anonymous$$ YOU SO $$anonymous$$UCH I have been stressing about this for so long now and if you couldn't tell i'm very new to c# so I thank you!
@Larry-Dietz THAN$$anonymous$$ YOU SO $$anonymous$$UCH this really bugged me for the past few days now and I've been searching youtube video after video thank you so much!!!!
Your answer
![](https://koobas.hobune.stream/wayback/20220612215815im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Camera isn't move position? Why my camera isn't change position? 0 Answers
Position of empty game objects 1 Answer
Trying to Generate Different Random Values for Position of Game Object Instances [C#] 1 Answer
Wrong position (always 0,0,0) when Instantiate prefab. 1 Answer
Raycast only occurs on start 2 Answers