- Home /
Help with sticky FP controller script
Hi all, Im in need of some guidance please! I want to create floating levels. They are made up of cubes. I have an FP controller. Say a path is 4 cubes in a row, edge to edge in a straight line, when the player reaches the end of the line of cubes the player will rotate 90 degrees and move onto the adjacent side of the end cube.Then again when the player moves forward they move to the underside of the cubes. I was thinking that I could tag the specific cubes that allow the player to transition to another side. Maybe when the player moves off the edge of such a cube, a check is performed and the player rotated to the new orientation. Any idea of the best way of doing this? Ideally Id want a smooth transition, so a player can stop pressing the movement key at any time and the rotation and movement stops and continues when the player presses the forward key. Cheers :D
Answer by HappyMoo · Jan 10, 2014 at 03:56 PM
Get rid of the FP controller. It would need very hacky code to prevent him from falling down. Write your own controller, which also adheres to your new rules, i.e. waking over edges and not being pulled down by gravity etc.
Another challenging part is to know when you can cross edges. It's probably best to configure this on the blocks themselves, but then you need to know on which block you currently are - maybe you're on the last block you touched(Collision). And you need to make sure the corners work... and that if you can cross an edge, but there's a block next to your current block, you actually continue to walk on that block and not rotate around the edge etc.
What happens if you try to walk into a non-rotating edge? You fall off or are you blocked? In case you fall off, what will the gravity be like? In the original direction (-y) or according to the last face you were standing on?
I use my own FP control script so that should be ok to modify. I If you walk to a non rotating edge then you are blocked. I found the walking on walls script here: http://answers.unity3d.com/questions/155907/basic-movement-walking-on-walls.html and I converted it to work with my controller in C# but 90 degree angles are not handled. I suppose I could use two planes with no rendering components to at the edge of the cube at right angles to one another to signal start and stop of rotation. Use lerp then to rotate around the edge?
When entering the edge, save some values like the edge position, the two planes the edge is between etc - what your script needs to do the animating, then set your players state to walkingOnEdge... And while you are in that stage, only allow right/left movements along the edge, but block at the sides of the edge and turn forwad/backward movement in a turn around the edge
Hmm yup.Id imagine Id need to use a probe to check if approaching edge. $$anonymous$$aybe do a raycast in the down dir from the very front of the player collider. If I keep the world cube based then can just presume there is a cube to rotate to. There is more to this control scheme than meets the eye.
Your answer
![](https://koobas.hobune.stream/wayback/20220613130021im_/https://answers.unity.com/themes/thub/images/avi.jpg)