character controller problem
hi folks, my problem is, that I want to prevent my character from falling down the edge of a platform. I could use an invisible wall, but I want to make it stop in its center, so my character could collide with something that's floating after the edge. Thought of various solutions but there's nothing useful coming to my mind.
Answer by Proclyon · Dec 09, 2010 at 11:04 AM
Use a SweepTest or CapsuleCast that represents the character to make an imaginary clone of your character controller. At the new location (Walk distance + 0.5 seconds?), now you have a short range scanner for falling and you can recognize the problem. Probably will need to get all colliders at that place.
Here's my own capsule cast Q&A which can shine some light on a similar problem
Here's the capsule cast script reference (Requires unity 3.0 or higher)
Here's the SweepTest (which projects the rigidbody itself rather than a collider)
Remember that you need to use a little tweaking and messing around with all this just to get it right. Is there no collider at +x 10 and -y 50? Well what if there is something in between? That will complicate things with casting, so u need to force transform a certain scan position. It's kind of tricky.
Now if you aren't thinking (this is to complicated) yet. I have to tell you. It is......
Simply go for invisible wall or set the object at the edge on a script or property that denies walking. Such as a script that gets the object on it if it has a character controller and sets it as child as long as the transform is on a certain X and releases it if you try to move to the "not fall down" side.
thank you, have to think and read about it, but that may be it...I'll let you know if it was ^^
Hi there, i am currently trying to use the Capsule Cast to solve the same problem but i just dont seem able to do it. can kindly advice on it?
Answer by oliver-jones · Dec 09, 2010 at 10:55 AM
I'm not really fully understanding your question (It could be me being a dumb a**). Let me try and understand your scene. Your character is on a floor (plane) and when he walks off, you don't want him to fall off the plane (floor)?
Could you explain your scene better?
You could increase the size of your characters collider?
hehe, my character walks to the right and is wider than high, so when he walks towards an edge, there would a part of him surpassing the edge without him falling from the plattform. His legs are in the center of the character controller. When I put a invisible wall after the edge of the platform his "belly" can't surpass the edge. I want him to push a button he can only reach that way. I hope you get the idea =)
Answer by OZAV · Apr 25, 2016 at 02:46 PM
. ..and, again, as i always say, this is kinda thread that will NEVER get old, as long a people make games in Unity. *Good that admins did NOT have it closed, thanks. So, here, (for now, and all future readers of this thread): you need to make in CODE, and define IN CODE a Square Matrix, after which bound player is considered out of it. Here's the (my simpler version) you can use, and additionally modify, for the task (you only MUST drag your center of your each map each time to be 0,0,0, in coordinates, for using this script in SUCCESSFUL manner) So, any objects you want to limit how far, or high it can go, just attach this script to it, and enter desired limits in Inspector: (*you may also add your damage call line, later, as well): here, my clean "LimitWorldBoundaries" script: LimitWorldBoundariesScr
Usually better to post the script (is that first thing a link? They tend to go bad.)
Your answer
Follow this Question
Related Questions
Special collision for players 1 Answer
How to smooth the movement of the camera? 0 Answers
Boat Controller Help 0 Answers
fps script not working 1 Answer
The type or namespace name 'CharacterController2D' could not be found 2 Answers