- Home /
Still trying to move walls
I'm working on a room inmy game which has some boxes(walls) that move back and forth blocking your way throgh the room. So what I have to do it place a box in between the 2 walls that are closing the way and jump over it while it holds the walls. In a diagram it looks like this:
XX -> is a THE BOX I must place in between the walls 1 -> start position of the walls 3 -> is where it would go if there was no box blocking the way, the way would be closed 2 -> is where it should stop if the box is in the way
in theory that's how I would solve it:
void Update() { wall1 moveTo point3, wait, moveTo point1;
if(wall1 hit box1)
{
wall1 moveTo point2, wait, moveTo point3;
}
}
or
void Update() { wall1 moveTo point3, wait, moveTo point1;
if(wall1 hit box1 and DistanceTraveled < distFrom(point1 to point3))
{
wall1 moveTo point2, wait, moveTo point3;
}
}
not sure if I will need to calculate the distance traveled. I've been stuck on this for ages. Someone please save me :)
Seriously... You waited 2 hours and post a duplicate question? Be patient and if you want to extend your question edit the old one but don't post the same question multiple times:
http://answers.unity3d.com/questions/181067/moving-walls.html
I tried to make it on a diferent way, that's why I posted 2 questions, to get diferent solutions. I still want to know what I asked on the other post, that's why I didn't edit it.
Answer by chemicalvamp · Oct 31, 2011 at 07:04 AM
Animate the wall and use http://unity3d.com/support/documentation/ScriptReference/Animation.Play.html
1st thing I tried doing was animating it, but my $$anonymous$$cher said it wouldn't work properly with the boxes in the way. Do you think it would work? I'll give another try anyway. Thanks
That is not really enough information on "the boxes" for us.. are they moved by physics or are they animated as well.. if they are animated you could just do the ti$$anonymous$$g so they are out of the way for the walls. if the boxes are stationary I dont see how they would affect the animation of the walls as long as you anticipate it.
They are moved by physics, as soon as I get time I'll try it out and post how it went here
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
How to move particles from script ? 3 Answers
Multiple Cars not working 1 Answer
How to move an object in world with script 1 Answer
Errors with gravity switching... 1 Answer