Forum rules - please read before posting.

Ground-check not working?

edited February 2018 in Technical Q&A
Hi Everyone, 

I just got AC 4 days ago and is now learning from the 3D game tutorial.

I want to use Direct control in my 3rd person player game, and wish to let the character jumps. In the player Physics settings, the Ground-check is "Default". 

The player can jump without problem, but it can keep jumping in the air, as well as changing directions, and not keeping the inertia in the air.

I tried changing the Ground-check to any layer, as well as the Collision Cube it is standing on to any layers, but it doesn't help except when the Ground-check is set to "Nothing" then it cannot jump at all.

I wish to make the player able to jump, walk, and change direction only on the ground, and keeps it horizontal travelling direction when in the air. What is the correct way to achieve this?

Thank you for your help.

Comments

  • Welcome to the community, @Rekize.

    Have you updated to the latest release, v1.61.0?  There was an issue related to jumping that has been fixed, so if you haven't yet upgraded please try the latest to see if it's now resolved for you.

    If it's persisting for you in the latest release, please post an image of your Player's full Inspector so that we can diagnose the problem.
  • edited February 2018
    Thanks for the help

    After updating to v1.61.0, I can no longer jump in the air.

    However another problem arise: It seems the player is only considered grounded when the "yellow sphere gizmo" (or is it the AC Player script?) is touching the ground; while it is considered not grounded when the capsule collider bottom is touching the ground.

    So the result is my player can only jump when the lower half of the body is sunk into the ground.

    Although this can be solved by rising everything (the sprite child, the Hotspot detector, and the capsule collider) by half the player body height, is there a way to adjust the height of the "yellow sphere"?

    I also wish the player not be able to change direction when not grounded. Is it possible to do that by settings? Otherwise may I do that by script?

    Thank for you help again.

    Here is my player inspector screenshots:
    image
    image
    image

  • Thanks for the images.

    The yellow sphere has no bearing on the ground check - it's there to indicate the distance from target destinations are considered "close enough".  If you increase the "Destination accuracy" slider in the Settings Manager (under Movement settings), you'll find it gets smaller.

    The Capsule Collider is what's used for ground checks, but it's necessary that the root position of the character is where the collider's bottom is.  We could confirm in a screenshot of the Scene window, but going by your Inspector shot it looks like the collider's Centre is in the centre, whereas it should have a "Y" value of 1.2 if the Height is correct.

    The 3D Demo's player character, Tin Pot, can be compared with for reference.  He can be found in /AdventureCreator/Demo/Resources.

    The prevention of movement while mid-air is a good suggestion - but one probably best left to custom script since that way you could introduce e.g. slower turning while jumping etc.  I've written such a script and added it to the wiki:

    http://adventure-creator.wikia.com/wiki/Lock_move_direction_while_jumping?venotify=created

    This works by remapping the InputGetAxisDelegate to give control over AC's reading of the Horizontal and Vertical axes, so that it can return the "last grounded" values while in mid-air.  For more on using delegates to overidde AC's input system, see the "Remapping inputs" chapter of the Manual.
  • edited February 2018
    Thanks a lot, it works as charm!

    Yet I changed the Input.GetAxis to Input.GetAxisRaw in line 19, as Input.GetAxis seems to take a while to return the value from 1 to 0, and it leads to the direction key being input in the air may be executed when the player reaches the ground.
  • Yeah, IIRC GetAxis will account for input settings such as Gravity / Sensitivity etc, while GetAxisRaw won't.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.