How to check position of player in 3D game?
Hi i will make a game,clone of Ballance(game) and i can not make a finish.How i will do that i make a skript
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
void position(srting name)
{if(string.name) Ypos = -25
Xpos = 59.89
Zpos = 156.33
public void LoadScene(string name)
Application.LoadLevel(name);(true)
}
}
But it does not work please say me what i do wrong?
Answer by hexagonius · Jan 15, 2016 at 03:00 PM
By the looks of it, you would need more knowledge about Unity and programming, sorry for that.
This might be a good entry point: https://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/coding-for-the-absolute-beginner
Work your way through what components are, how you use GetComponent and then try again.
About your code:
You do not use Unity's callbacks (Start, Update...), the syntax is incorrect and you're not accessing any transform component, which is mandatory for knowing any position of anything.
Yes i am a noob in unity.And i think do finish with coliders but i cant.
Answer by Jem_Stone · Jan 20, 2016 at 10:47 PM
Like this:
public GameObject Player;
int Xpos;
int Ypos;
int Zpos:
void CheckPoistion () {
Xpos = Player.transform.X;
Ypos = Player.transform.Y;
Zpos = Player.transform.Z;
}