- Home /
Flinging Wall Death
Hey guys,
I have a very specific problem, and I'm not sure what approach I should use to solve it. I have a cuboid, which is the player. The user controls him around the gridded map by rotating, in order to get to the end tile.
Currently, there isn't a specific grid, but the player moves in such a way that it seems that he is constrained to a grid. I want it so that when the player has even a little bit of him over the edge of the map, the player doesn't get destroyed, but the boundary flings him off the map, and an invisible box collider on the bottom destroys it. How would I make it so that the boundary wall would detect the player and fling him off?
The player is outlined in red. One of the boundaries that surrounds the map has its mesh renderer visible so you guys can see it (in the actual game it is invisible). It is outlined in blue. Below the entire map is the deadly floor that is invisible, but selected so you guys can see its outline.
It is somewhat similar to the game below: https://www.youtube.com/watch?v=bheCWlrtp-o
Answer by screenname_taken · Jul 04, 2014 at 06:10 PM
make the wall box a trigger, and on trigger enter, suck it out of the grid. If you have a rigidbody use forces, if not translate the cuboid. (I had a game like that on my blackberry. loved it.)
The player does have a rigidbody on it. I know how to use rigidbody.AddForce, but how would I detect what direction it should suck the player in?
I guess you can look at the object's velocity, it shows which way it's going. Read that, and give it back in as a force.
I'm a little confused on how I would do that but thanks!
read rigidbody.velocity and store it in a vector3. velocity is showing the direction a body is moving towards. then multiply that vector3 with your speed (if you want to slow it down or make it go faster) and apply it as a force.
Your answer
Follow this Question
Related Questions
Save player position when trigger is destroyed 1 Answer
Distribute terrain in zones 3 Answers
Guided missile help c# 1 Answer
Holding objects, How to deal with object clipping 2 Answers
col.gameObject.layer is not working 1 Answer