Forum rules - please read before posting.

NavMesh in different Rooms

edited April 2014 in Technical Q&A
First of all Hi ;) I'm new here...and I'm in love with AC :)

2 simple questions:

a) I have the first floor of an house and my navmesh is simply all the base of the first floor...the problem is I can click the navmesh trough the walls and my character just move in that direction...how can I fix this?

b) If I have stairs how can I say to the character to change animation to go up or down? Can I add a variable like height or something like that? I'm using mecanim atm

thx so much :)

Comments

  • No ones can help me? O I need to be more specific? something not clear on the questions? :(

  • a) Not sure what your problem is here. Is your character moving though walls? Is your navmesh taking the walls into account?
    b) You could have a trigger by the stairs where you change the animation for your character. Your navmesh should follow the stairs, so you won't need a height variable.
  • A) imagine ur character is inside a closed room inside a house. All the navmesh is the floor of the entire house. If I click through the walls to a point of the navmesh the character start run to the point...

    B) if put a trigger to change the animation can I still move on the stairs? Like Don't want to go all over the stairs but just in the middle...

    Thx
  • Chris are u around? :(
  • Patience, Sparta, patience!
    Buying an AC license does not include a 24/7 Service Level Agreement with response time <24h ...
    Work on something else while waiting for someone (maybe Chris) to help for your particular problem.
    Cheers,
    orrence.
  • edited April 2014
    What Orrence said. As for your questions I feel that we still need more detail in order to help you: Do you make a 2d or 3d game? Is your navmesh Unity based or custom? Maybe you can link to a screenshot to show how your current navmesh is laid out in your scene?

    a) if your navmesh is Unity based: have you baked it?
    b) your navmesh will decide where on the stairs you are able to go.
  • a) If you mean that you are clicking through walls to pathfind to rooms that the player cannot see, try placing down CollisionCubes over the walls to block the cursor.  If that fails too, try changing the layer of those particular CollisionCubes to NavMesh.

    b) You could use the Character: Animate action to set a bool like "IsClimbingStairs" when on the stairs, but this wouldn't change based on direction.  For that, you'd need to write a custom script that affects a Mecanim parameter based on the change in the Player's height while moving.
  • edited April 2014
    hey chris thx for the reply.

    So I tried to put collissions cube on the walls but the character still finds the way to the other rooms...if I put the collission cubes on the navmesh layer he continue to walk like he's trying to reach a point behind the wall...what can I do? :(

    Edit: the character continues to move only iif he's walking...if he runs to the wall he stops...can't figure why...
  • edited April 2014
    Looks like a bug!  Will get a fix out for 1.30, but in the meantime, try this: PlayerMovement.cs, line 485.

    Replace:

    if (settingsManager && sceneSettings && Physics.Raycast (ray, out hit, settingsManager.navMeshRaycastLength, 1 << LayerMask.NameToLayer (settingsManager.navMeshLayer)))
    {


    with:

    if (settingsManager && sceneSettings && Physics.Raycast (ray, out hit, settingsManager.navMeshRaycastLength))
    {
      if (hit.collider.gameObject.layer != LayerMask.NameToLayer (settingsManager.navMeshLayer))
      {
        return false;
      }

    Then lay down a CollisionCube over the walls, only place it on the Default layer.
  • Hi Chris. That workaround works to an extent but if the collision cube is in FRONT on the camera, it's impossible to click anywhere as the cube isn't ignoring the raycast.
  • I'm not following.  Screenshot / diagram?
  • Actually scratch that - If the camera's static I don't need a collision cube.

    But here's what I meant anyhow:

    image

    I've added the area the camera roughly covers so you can see what I mean.

    I hope this makes sense?
  • You're saying scratch that - not sure if this is still a problem.  Either way, you can disable/re-enable Collision Cubes by using the Object: Send message Action to call Turn On and Turn Off.
  • Yes but turning them off would mean the player can walk anywhere. 

    For example, the player enters a dark room and can only walk in a small area near the door until he finds the light switch and turns it on. Only then can he walk anywhere else in the room.
  • U could use 2 different navmeshes...one when the lights are off and one when the lights are on...there is a function to switch navmeshes like in the basement demo before and after the barrel rolls on the ground. I hope this will help
  • I'm not using Nav Meshes though, I'm using Nav Segments.
  • In this case, I would recommend @ThisIsSparta's advice and go with custom NavMeshes.

    However, you may be able to get around this simply by lowering the CollisionCube such that the top of it is only about a foot above the floor.  The character won't be able to move past it, but you'll be able to click on the correct part of the floor.
  • Correct me if I'm wrong, but can't you also add a movable script to some of your navmesh segments so that you can have them move into the desired position (say from x=100 to x=0) when your light switch action takes place? 

    In other words, start the scene with them far away from the intended area, then when the light switch is turned on, run an object: transform action which moves the desired segment or group of segments to the intended position.

  • @skitt2501 - Nice idea, that may well do it!  You'd also need to add the RememberTransform script to the moving Segment, to make sure it's position is recorded in save games.
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.