Question by
yujinjjang · Mar 19, 2017 at 12:26 PM ·
characterif-statementsproblema
Moving coordinate conditional problem
IEnumerator Start () { while (true) { ob = Charac.transform.position.x; obb = Charac.transform.position.z;
if (Charac.transform.position.x < ob) {
transform.position = new Vector3 (Random.Range (Charac.transform.position.x - 50, Charac.transform.position.x - 100), Charac.transform.position.y - 10,
Random.Range (Charac.transform.position.z + 25, Charac.transform.position.z - 25));
Instantiate (pt, transform.position, transform.rotation);
} else if (Charac.transform.position.x > ob) {
transform.position = new Vector3 (Random.Range (Charac.transform.position.x + 50, Charac.transform.position.x + 100), Charac.transform.position.y - 10,
Random.Range (Charac.transform.position.z + 25, Charac.transform.position.z - 25));
Instantiate (pt, transform.position, transform.rotation);
} else if (Charac.transform.position.z > obb) {
transform.position = new Vector3 (Random.Range (Charac.transform.position.x + 25, Charac.transform.position.x - 25), Charac.transform.position.y - 10,
Random.Range (Charac.transform.position.z + 50, Charac.transform.position.z + 100));
Instantiate (pt, transform.position, transform.rotation);
} else if (Charac.transform.position.z < obb) {
transform.position = new Vector3 (Random.Range (Charac.transform.position.x + 25, Charac.transform.position.x - 25), Charac.transform.position.y - 10,
Random.Range (Charac.transform.position.z - 50, Charac.transform.position.z - 100));
Instantiate (pt, transform.position, transform.rotation);
}
yield return new WaitForSeconds (interval);
}
We want the object to run according to the condition that the coordinates move when the character coordinates move. However, the object does not run properly. I do not know the problem. Plz ...
Comment
Your answer
Follow this Question
Related Questions
Text Adventure help! 0 Answers
Doomed animation (Inverse kinematics) 0 Answers
How to make an animated object inside inventory. 0 Answers
align player to object location in C#? 0 Answers
My character always stay in T-pose (game launched)... 2 Answers