- Home /
Question by
acciaio00inox · Apr 16, 2014 at 06:52 PM ·
playerspawnmove
Why this spawnpoint script locks my player?
With this JS code my player can't move. What's the problem? Vector3? If i disable this script, my player can move. I need to learn more.
CP = CeckPoint getCP = current CP Respawnable = a player that can respawn :/
The code
#pragma strict
//OGGETTI CONFIGURABILI
var Respawnable : Transform;
var CP1X : float;
var CP1Y : float;
var CP1Z : float;
var CP2X : float;
var CP2Y : float;
var CP2Z : float;
var CP3X : float;
var CP3Y : float;
var CP3Z : float;
var CP4X : float;
var CP4Y : float;
var CP4Z : float;
var SpawnX : float;
var SpawnY : float;
var SpawnZ : float;
//***************************
function Update () {
var posX = Respawnable.position.x;
var getCP : int;
getCP = 0;
//CeckPoint
if (posX > CP4X){ //CP 4
if (getCP < 4) {
getCP = 4;
}
else if (posX > CP3X){ // CP 3
if (getCP < 3) {
getCP = 3;
}
}
else if (posX > CP2X){ // CP 2
if (getCP < 2) {
getCP = 2;
}
}
else if (posX > CP1X){ // CP 1
if (getCP < 1) {
getCP = 1;
}
}
}
if (Respawnable.position.y < -20) {
Debug.Log("Respawning");
if (getCP == 4) {
Respawnable.position = Vector3(CP4X, CP4Y, CP4Z);
}
else if (getCP == 3) {
Respawnable.position = Vector3(CP3X, CP3Y, CP3Z);
}
else if (getCP == 2) {
Respawnable.position = Vector3(CP2X, CP2Y, CP2Z);
}
else if (getCP == 1) {
Respawnable.position = Vector3(CP1X, CP1Y, CP1Z);
}
}
else if (getCP == 0) {
Respawnable.position = Vector3(SpawnX, SpawnY, SpawnZ);
}
}
Plz help me. :D
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613142857im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Player move and camera problem 2 Answers
Collision problem when spawning in the collider 1 Answer
How to use tag for all players in the Instantiate. 0 Answers
How to move a player to a certain point? 0 Answers
Player can't move. 1 Answer