• Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By Epicghost 505
      Hello,
      We are looking for people to be apart of a team, to help create a horror game we are looking for 3d modelers, coders, artist, animators, fx artist, level designers, and audio design, there will be a payment plan once release of game                                                                                                                                                                                                                                                                                              if your interested come join our discord                                                                                                                                                                                                                                                                         We hope to see you there
      https://discord.gg/6rcc6xr
      -Epicghost505
    • By wobbegong_
      I am taking an absolute beginner's game development course and we have just finished game jams in small groups. Our current assignment is to get feedback from people working in any aspect of game development. I would very much appreciate any feedback! The game is up on itchi.io (sound warning) https://wobbegong.itch.io/zombie-shooter It's essentially a very basic PvE.
      I also have some things I'm wondering about, but you don't necessarily have to answer these. 
      1. Do you have any tips on working with physics? My group wrestled a bit with Rigidbody physics not totally working the way we wanted to -- jumping ended up kind of floaty and inclines seem to mess up movement. Alternatively... how can I build terrains with depth that won't result in wonky physics?
      2. How can I keep up the level of challenge in an interesting way as the player progresses through the waves?
      3. What are some of your personal guidelines for creating title screens?
      Thank you very much in advance!
    • By lxjk
      Hi guys,
      There are many ways to do light culling in tile-based shading. I've been playing with this idea for a while, and just want to throw it out there.
      Because tile frustums are general small compared to light radius, I tried using cone test to reduce false positives introduced by commonly used sphere-frustum test.
      On top of that, I use distance to camera rather than depth for near/far test (aka. sliced by spheres).
      This method can be naturally extended to clustered light culling as well.
      The following image shows the general ideas

       
      Performance-wise I get around 15% improvement over sphere-frustum test. You can also see how a single light performs as the following: from left to right (1) standard rendering of a point light; then tiles passed the test of (2) sphere-frustum test; (3) cone test; (4) spherical-sliced cone test
       

       
      I put the details in my blog post (https://lxjk.github.io/2018/03/25/Improve-Tile-based-Light-Culling-with-Spherical-sliced-Cone.html), GLSL source code included!
       
      Eric
    • By Octane_Test
      I am developing a mini golf game in Scenekit. I have applied dynamic physics body to the ball and static physics body to the grass surface and the brick walls show in this image.
      Issue:
      When I apply the force to the ball, the ball’s linear and angular speeds change as shown in the graphs.  The ball’s speeds don’t reduce to zero (so that the ball can stop) but remains constant after certain value.
      Ball linear speed graph
      Ball angular speed graph
      Analysis Tests:
      When I increase the values to both the rolling friction and the friction, the ball speed is reduced quickly but remains constant after certain value (similar to the above graphs). When I increase the values of the linear damping and the angular damping, the ball speed behavior is same as the point #1. When I set the gravity value to -9.8 m/s2, the ball’s linear speed remains constant after 0.1 m/s. If I reduce the gravity value to -5 m/s2, the ball’s linear speed remains constant after 0.05 m/s. The friction, linear friction, linear damping and angular damping are same throughout the motion of the ball.
      There is 1 millimeter overlapping between the ball and the surface of the golf course.
      Questions:
      From the analysis test #3, I think the gravity is causing the constant ball speed issue. Is my assumption correct? If yes, how can I fix the issue? I can’t remove the gravity field as without the gravity field the ball will not roll along the grass and it will slide. Why the friction and the damping properties are not affecting the ball speed after certain value?
      Are there any other physics properties can cause such issue?
      From the analysis test #5, are there any chances that the ball is receiving upward push to correct the position of the ball?
      Solutions:
      If I increase the physics timestep from 60 FPS to 200 FPS, the issue is resolved. I am not able to understand how this change can fix this issue? After reducing the gravity value to -1 m/s2 and physics simulation speed to 4 (4 times fast physics simulation), the issue is fixed. Again, I am not able to understand how this change fix the issue? I would appreciate any suggestions and thoughts on this topic. Thank you.
    • By ethancodes
      I'm having a weird issue with detecting a collision. I've tried everything I could find online but nothing seems to work. I have a brick object. It has a 2D Collider attached and I have also attached a 2D Rigidbody on it. I also have an EndScreen 2D Collider. The EndScreen 2D collider is tagged with "EndScreen". I am trying to detect when a brick collides with the end screen collider and simply print "game over" in the console. 
      This is my current code for this part of the program, it is attached to the bricks:
      void OnCollisionEnter (Collision2D collision) { if (collision.gameObject.tag == "EndScreen") { Debug.Log("Game over"); } } Several things have happened depending on the set up. If I have the rigidbody 2D set as static, my ball object can still collide with the bricks, but I get no Log message. If I set it to Kinematic or Dynamic, I get absolutely no interaction between the ball and the bricks, and nothing when the bricks pass through the collider. I have tried to set the collider to a trigger and use OnTriggerEnter2D, no change. I have tried to put the rigidbody on the EndScreen object and tried to set it's body type to all 3 settings, no change. The only thing I can think of that I have not done is put the script on the EndScreen object and switch the tag to the bricks. The reason I have not done this is because I will have several types of bricks, some of which will have different tags. 
       
      Please tell me somebody can see what I'm doing wrong here, because I'm losing my mind over something I feel should be ridiculously simple. Thanks.
  • Advertisement
  • Advertisement

Best way to implement wall jump?

Recommended Posts

I'm trying to implement a wall jump but I don't know what the best way to go about doing it is. Specifically, I don't know how to deal with the collision between the player and wall.

Obviously I want the game to know that what the player just collided with was a wall which is at the correct angle to allow a wall jump; A wall angled at a 75 degree angle naturally wouldn't be acceptable for wall jumping. So my question is, what would be the best way to calculate this collision (in Unity)? Would I get the normal vector of the wall to use for a specific range, and if so, how? Or is there another, better way to do it?

 

Thanks, all help appreciated!

Share this post


Link to post
Share on other sites
Advertisement

One way -- perhaps not the best way for your game, I don't know -- is this:

Create a new layer and a zero-friction physics material with that layer mask. Apply this as a physics collider to all your walls that allow a wall jump.

In your character controller, if the person jumps you should already be doing a test to see if they are touching the ground. In this case add a second test: if they are not on the ground then see if they are within a radius of the physics object. That's either Physics2D.OverlapCircle() or Physics.OverlapSphere(), and pass in the layer mask used for your walls. That will tell you if you are close enough.

You can do more advanced checks if you want to loop through the results. OverlapSphere() returns all the colliders and you can do your more advanced tests with them if you'd like.

 

Share this post


Link to post
Share on other sites

I think you're on the right track. You'll have the normal of the surface in OnCollisionEnter(collision) in collision.contacts, in contact.normal. Just use the dot product to determine if this surface isn't right for a wall jump. https://en.wikipedia.org/wiki/Dot_product

If 90 to 75 degrees is your range of acceptable walls for jumping than any wall that satisfies the correct conditions will have cos(75 degrees) => Vector3.Dot(<surface normal>, <up vector>).

Share this post


Link to post
Share on other sites

Responding to a collision may not give the desired results. It potentially gives an extremely small window, perhaps even a single mid-frame update (since those should be done in the fixed update of physics rather than the randomly-paced graphical update time). 

By running it on a sphere of arbitrary size that you describe using Physics.OverlapSphere(), the developer or designer can fine-tune the distance wall-jumping needs. 

Share this post


Link to post
Share on other sites
5 hours ago, samoan62 said:

I think you're on the right track. You'll have the normal of the surface in OnCollisionEnter(collision) in collision.contacts, in contact.normal. Just use the dot product to determine if this surface isn't right for a wall jump. https://en.wikipedia.org/wiki/Dot_product

If 90 to 75 degrees is your range of acceptable walls for jumping than any wall that satisfies the correct conditions will have cos(75 degrees) => Vector3.Dot(<surface normal>, <up vector>).

Thanks. 

About the last bit- what does the cosine (and sin/tan) produce? And how do you know, in Unity, which one to  use?

Share this post


Link to post
Share on other sites
On 7/14/2017 at 4:29 PM, frob said:

By running it on a sphere of arbitrary size that you describe using Physics.OverlapSphere(), the developer or designer can fine-tune the distance wall-jumping needs. 

I suppose you're right that OnCollissionEnter being called outside of FixedUpdate() can lead to awkward race condition scenarios. I never really thought of that. I use OnCollissionEnter because OverlapSphere only returns Collider[] and it's very weird to try and get things like distance between the two objects or normal of the closest surface. I have yet to find a good way of doing this.

 

20 hours ago, Manyula said:

About the last bit- what does the cosine (and sin/tan) produce? And how do you know, in Unity, which one to  use?

If you look into the dot product, the most meaningful thing to take away is that the dot product of two vectors (normalized vectors in this case) is equal to the cosine of the angle between them. cos(75 degrees) is about .25, so your code would really say:

if(0.25f => Mathf.Abs(Vector3.Dot(<surface normal>, <up vector>))).....

If you notice that that number (.25) is too lenient you can always decrease it a little or increase it if you'd like more horizontal walls to be valid.

Share this post


Link to post
Share on other sites

This thread contains everything you need to implement wall jumps, but since I know you're going for a sm64 style this might simplify the implementation a bit.

In sm64, you can only wall jump off a surface if its surface normal is parallel to the player's floor plane. We talked a bit about rotating the gameplay plane, but assuming youre sticking with the world x/z plane, you can assume that all walljump-able surfaces have a surface normal whose y-component is 0.

To get the surface normal of the surface you're hitting, just raycast from the player's position along its forward vector. The raycasthit object will contain the struck surface's normal.

If you use another method to get the surface normal you'll have to ensure the player is hitting the wall from in front, not beside or behind with dot product. But using a raycast to get the normal can guarantee this if you set it up right. Note however that if you hit the wall too widely in sm64 you can't wall jump off it, so maybe add an angle check between the player forward and the wall's normal and ensure it's within a certain theshold (sm64 feels like it's slightly more than 45 degrees)

SM64 walljumps always have the same horizontal trajectory relative to the surface normal (reflect player forward off the wall's normal - http://www.3dkingdoms.com/weekly/weekly.php?a=2). Their speed is affected by how early in the walljump window the jump button is pressed (first possible frame always goes furthest), and their height by how long you hold the jump button, as is normal for mario air physics.

Edited by cmac

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Advertisement