|
/Free Cake for anyone who can solve this/ I'm trying to write a Walljumping function using Vector.Reflect, and I managed to getting to work somewhat, but the reflection only works when the character is facing the forward direction (if the camera is facing behind him).
How can I adjust the Reflection Direction so that the character will go into the opposite direction when he jumps against the wall, no matter where he jumps from? If you need to see how the movement is set up, check it below:
(comments are locked)
|
|
Like Bunny said, you want to use hit.normal. However, you don't want to reflect it at all. What you would actually want to do is to apply the normal + Vector3.up when the character is using the wall jump. You also might want to apply a wall jump variable. Like so: Also be aware that you might need to change your character's forward to match the new direction. This is much different than a true reflection of the character's velocity. As you may have noticed, most games make the player jump between two walls to get to the top. They take the perpendicular direction (the normal) and send the character that way. Now just make sure you trip your flag off once the total force is applied. Thanks, kinda got it working for the most part, the tripping flag tripping however needs to be tweaked, because the player will just stop and free fall...
Sep 27 '11 at 01:17 AM
SirVictory
Of course that's another way but it's an unnatural movement. If you jump at the wall in an narrow angle you would suggest to jump from the wall in the same angle and not 90° off the wall. Adding additional up-speed is self-evident since you perform a jump.
Sep 27 '11 at 03:13 AM
Bunny83
(comments are locked)
|
|
You have to reflect the movedirection at the surface normal and not at Vector3.forward. You have to save the normal-vector when you hit the wall so you can use it when you want to walljump. You have to implement a OnControllerColliderHit function and there check for a side-collision and save the hit.normal in a variable. how do you do this? could you give an example?
Nov 30 '12 at 03:49 AM
shane.rachel
Just use Vector3.Reflect like in the question above but use the hit normal as surface normal ;)
Nov 30 '12 at 09:30 AM
Bunny83
It's funny. A year later, and this is also seems elementary to me :D
Nov 30 '12 at 09:33 AM
SirVictory
(comments are locked)
|
