- Home /
portal problem
hi, im trying to make a portal for a pacman type game. The rule is, when you enter the left side portal you will spawn to the right side portal and vice versa. the transport to the other side works fine. The problem is that the character is stocked to the spawn area. look at my code:
This for the Spawnpoint script :
static var post;
static var travel = false;
var Portal1 = false;
var Portal2 = false;
static var p1;
static var p2;
function Update()
{
Portal1 = toPortal1.Portal1;
Portal2 = toPortal2.Portal2;
if(Portal1==true)
{
p1 = true;
post = transform.position = GameObject.FindWithTag("portal1").transform.position;
travel = true;
}
if(Portal2==true)
{
post = transform.position = GameObject.FindWithTag("portal2").transform.position;
travel = true;
}
}
function OnLevelWasLoaded(thisLevel: int)
{
post = transform.position = GameObject.FindWithTag("spawn").transform.position;
travel = true;
}
and this is to one of my portal script :
static var Portal1;
function Start ()
{
transform.collider.isTrigger = true;
Portal1=false;
}
function OnTriggerEnter (col : Collider)
{
if(col.gameObject.tag == "TIGER" )
{
transform.collider.isTrigger = true;
renderer.enabled = false;
Portal1 = true;
}
}
i hope that someone can identify the problem..thanks
Not sure what you mean by "stocked", can you elaborate please?
after transferring to the other portal, the character doesnt move anymore.. it stays there
After it gets moved and whilst running the game are the scripts still attached to the gameObject?
Also Its a but hard to read your script given all the variables are implicit but you might be causing it to continually go through the portals.
Answer by sacredgeometry · Feb 11, 2012 at 02:32 PM
Your script is over complicated for just a simple transporting script. All you need to do is :
var portal2 : GameObject;
function OnTriggerEnter (col: Collider){
if(col.gameObject.tag == "TIGER" && portal2.gameObject.active == true) {
col.gameObject.transform.position = portal2.transform.position;
renderer.enabled = false;
}
}
This should do a transportation on its own without the other bits. Sorry if this doesn't answer your question, but i cant see a problem with your script other than you might have intersecting colliders which are stopping your character from moving.
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Change spawn position, even when changing scene 2 Answers
Animation by Scripting point A to B 1 Answer
Spawning Error.. 0 Answers
Mysterious Rect problem 1 Answer