Forum rules - please read before posting.

2 Nav Meshes - hole in the middle of the way

Hello there! 🙂
There is a hole in the middle where you cant walk. After solving you reach the other side. I would go for 2 nav meshes. But if the player is on the other side the second mesh is not active. How can I turn off /on both meshes? Or would it be better 1 mesh and blocking the player? I do not know, how to get a little further. Thanks a lot!
If I put a mesh hole into the mesh the player just walks around, but there should be no space. strange.

What does "bake" mean and what is it for in the nav mesh inspector?
thanks a lot.

Comments

  • edited December 2021

    Welcome to the community, @tibao.

    The answer depends on whether you're working in 2D or 3D. Since you mention "bake" showing in the Inspector, though, I'm assuming this is for a 2D scene.

    When it comes to a 2D NavMesh, you should avoid "blocking" the Player from accessing part of it using regular colliders - the NavMesh's shape should always cover the exact area you want them to be able to access.

    A NavMesh hole cannot carve out a NavMesh entirely - it must be surrounded by the original NavMesh all the way around.

    A NavMesh can have multiple PolygonCollider2D components attached, however, so long as they do not intersect. This is useful for situations when you have two areas that are not connected - see the second page of the Manual's "Polygon Collider pathfinding" chapter for details.

    You can also update the NavMesh at runtime by using the Scene: Change setting Action - to either replace the NavMesh, or add/remove holes.

    I'm only talking generally here, but if you can share some screenshots to illustrate your exact situation I can try to give more specific advice.

    What does "bake" mean and what is it for in the nav mesh inspector?

    The "Bake" option causes the NavMesh to pre-calculate data about the NavMesh to avoid having to do it when the scene begins. I'd recommend leaving this alone for now.

  • edited December 2021

    wow, what a response time. I am doing this for 3 days now and watched some of your and Jeremys tuts quite a few times. But some things are not working for me.

    Attached you find your character and a new background with the gap. Mesh default right and mehs right. I tried to trigger him, that works. But if I teleport to left he wants to get back to right. The trigger is not the best solution. If he hits the trigger he can say "wow, deep". But for navigation maybe not the best way because it stil moves if you click like nuts. And pathfinding back is anoying.
    Maybe you have a good solution.

    Some more problems with the tuts: The highlight script on sprites (itmes) does not work for me. I tried it on sprite on the picture itself but it will not glow up on hovering with mouse. Or should it do something else?

    Animations: This is my biggest problem. They all start correct, but then stop 3/4 of the frames. Or they animate, but there are no transforms x,y.
    Where should the animations be modeled so the size of the character and the distance will be like in the game? Sometimes the character moves way to far.
    In this example attached I just use the clock and then he jumps > as a test.
    But if I use the clock on different spots (he is not walking to a marker for test purpose), depending where he is standing he jumps only a few pixels and other times he flys out of the screen. But the difference where he stand is only a few pixels away. This is really strange. I know this is not ACs problem, but it sticks together. I watched lots of animations and tried to find how you do the animation starting, stopping in your demo because this is not in your video tuts. But I cannot figure out how you combine all this, so it does that what it should do. This is the biggest frustrating part right now.

    Sorry for so many questions. Take your time.
    I love the AC and hope I will get along to do my first adventure game. I already did some variable stuff and is fun. Hope I can fix my issues some day.

    Here the scene
    https://ibb.co/XskQMsN

  • edited December 2021

    Is it possible, that my problems with the position (transfom) a problem with my character is? I watched your 2 tut the 4th time and then I noticed that my sprite is not a prefab. Instead my parent object of the sprite is a prefab. I cannot change that. I tried.

    Do I have to create my character completley new or can this be fixed?

    I still dont know why this is a prefab and what it actually does?
    In your 2D Demo all cutscenes are prefab and I do not know why.

  • Sound_power from the discord helped with the mesh problem and it works. I am so happy. Now we need to solve the highlight and the animation probs.

  • edited December 2021

    Don't worry - we can sort out all these issues - though could you share some screenshots or gifs/video to illustrate your animation problems? I'm afraid I'm not sure I'm following your description exactly, and visual problems are often best seen to be understood properly.

    For standard animations like idle/walk etc to loop, you will have to check "Loop Time" in their Inspectors. You will also need to supply animations for each of the directions defined in the character's Inspector's "Facing directions" field.

    Do these issues occur with the 2D Demo's Player prefab, Brain2D? With your own character, check the Console for potential warnings. One of the key things about 2D characters is that their "sprite child" needs to have a local position of 0,0,0 (so that it's in the same position as its root object). If this isn't the case, you can end up with the character appearing to move incorrectly.

    The easiest way to tell where the character is "really" positioned (as opposed to visually) is to enable Gizmos at the top of the Game Window, and select your Player in the Hierarchy. If you're spawning them in from the Settings Manager, they'll appear underneath the "DontDestroyOnLoad" foldout at the bottom. When selected in this way, you'll see their AudioSource gizmo at the character's true position - you can see this by Brain's feet in your screenshot.

    A text-based tutorial on creating 2D characters can be found here. You may find this more helpful than the video tutorial.

    For the highlighting: are you referring to items in the Inventory, or Hotspots in the scene? For Hotspots, you will need to attach a Highlight component to your sprite and then assign it in the Hotspot's Highlight field. For items, you'll need to assign a separate "highlighted item" graphic in the item's "Active graphic" property. If you can share some images of the objects involved, I can try to spot where the issue lies.

    The fact that the cutscenes are prefabs in the 2D Demo can be ignored - in a much older AC version, prefab links were retained when adding them to the scene, but this is no longer the case. So long as the prefabs themselves are not edited, however, the scene should not be affected.

    If you want to unpack a scene instance of a prefab, you can do so by right-clicking it in the Hierarchy and choosing "Unpack Prefab Completely" in the menu.

  • the standard animations are working properly. the animations which are triggered by a cutscene or by "use" trigger. They are not proper placed and do not animate like I see them in the Antimation preview/scene.

    The position of the character Sprite is 0,0. If I move the sprite in the game the inspector says 0,0. The jump is executed vertical but not horizontal. really strange. I cannot figure that out.

    I want to highlight items in the screen. If you hover the items they go bright. Is that wrong? Ok, I thought if you use this script the highlight is done to the not transparent area and brighten it up to white 50%. You wrote that the item must be replaced by a item which is highlightend by hand in a grafic program for example?

    I still do not get what prefabs are, sorry.

  • edited December 2021

    the animations which are triggered by a cutscene or by "use" trigger. They are not proper placed and do not animate like I see them in the Animation preview/scene.

    What are your AC and Unity versions, and how are you triggering these non-standard animations? If you're saying these animations don't play in full, does the character return to their "idle" animation state?

    The "Character: Animate" Action has "Wait until finish?" and "Return to idle after?" options depending on your settings, but you can optionally uncheck these and instead add on an "Engine: Wait" Action of the same duration. Does that allow them to play in full?

    The position of the character Sprite is 0,0. If I move the sprite in the game the inspector says 0,0. The jump is executed vertical but not horizontal.

    If you update the position manually and it reverts back, then it's likely that it's being set through animation. The sprite child's position should typically be at 0,0,0 under normal circumstances, and only changed through animation and specific times.

    I will need to see images to illustrate the issue here. Please share screenshots of as much as you can - including the exact properties you're controlling in the animation window.

    I want to highlight items in the screen. If you hover the items they go bright. Is that wrong? Ok, I thought if you use this script the highlight is done to the not transparent area and brighten it up to white 50%.

    Hotspots should be brightened when hovered over. Are you getting any effect? I'll need to see screenshots here of a typical Hotspot, and the Inspector of an object that has the Highlight component attached.

    Are you relying on Unity's built-in render pipeline, or URP/HDRP?

    You wrote that the item must be replaced by a item which is highlightend by hand in a grafic program for example?

    In AC terms, "item" refers to an inventory item that the player can carry and appears in their inventory menu. Assigning a separate graphic is the workflow for these inventory items - not for objects within the scene.

    I still do not get what prefabs are, sorry.

    Prefabs are a way of storing a scene object so that it can be re-used elsewhere in your game. They are a Unity concept, and not anything specific to AC. If you're unfamiliar with them, I would strongly recommend looking through Unity's own beginner tutorials to get familiar with Unity's core concepts.

  • edited December 2021

    Answers to
    1. I have the newest unity and AC, because using them for a week now.
    I tried both methods "wait" and all checkboxes. But is the same.
    2. The highlight works now. I forgot to reference the object to highlight
    3 + 4. I will check this, too.

    About the animation problems I try to ask someone in the discord.

    I will get back again...

  • By all means, the discord is a great source of knowledge - but it is community-led and not for official support. I will need to see images of your animation issues in order to help.

  • edited December 2021

    So nice guy helped me with the animation problems and we could fix a problem, but he doesnt know why it is like this and my project/scene behaves very strange.

    If animations are in the preview scene the sprites are moving like they should. But in the game they are completely somewhere else. I think this is not right, isnt it?

    I think I will reset with a new project, but this is a bummer because it all was setup like I wanted to :-(

    The 2D Demo is not working properly, too. Is there a way to reimport it again?

  • I think this is not right, isnt it?

    I'm afraid I cannot comment without seeing the issue for myself. I'm here and ready to help - but I will need to see screenshots that explain and illustrate the issue.

    The 2D Demo is not working properly, too. Is there a way to reimport it again?

    You can re-import AC from Unity's Package Manager.

    In what way is the 2D Demo not working? Generally, there are two main possible causes:

    1. The original assets, prefabs included, have been modified. If you opt to re-import from the Package Manager, look for the /AdventureCreator/Prefabs and /AdventureCreator/2D Demo sections of the import window - it should indicate whether or not this is the case, because unchanged assets will be greyed-out.
    2. You are running the 2D Demo without the 2D Demo's Managers assigned. The safest way to run the demo is to open it via "Adventure Creator" menu in the top toolbar, as this will assign the correct Managers before opening the 2D Demo scene.
  • Thanks a lot for helping. This time with screenshots. I hope will will solve this problem with the animation, too.

    After an animation, the Child (Sprite) position is not 0,0,0 anymore, because the Sprite did the movement of the animation. So next time you move the sprite the parent is not matching the Sprite. See picture. The yellow circle is far away from the Sprite. So the difference is the end position of the animation.
    https://ibb.co/FBX5CTN

    Is there a way to solve this problem without C# inside AC?

    We tried to solve this problem with an Call Event via C#, which shall reset the position of the Sprite. But for some reason it cannot be called. Someone who knows coding very well. But he could not call this script in the Action List.

    In his environment it works, in mine not. He has an older AC Version:
    https://ibb.co/86bfmWQ

    This is the C# script:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class PostionAfterAnimation : MonoBehaviour
    {
    public GameObject playerSprite;

    // Start is called before the first frame update
    void Start()
    {
    
    }
    
    // Update is called once per frame
    void Update()
    {
    
    }
    public void ResetPos()
    {
        playerSprite.transform.position = new Vector3(0, 0, 0);
    }
    

    }

  • Thanks for the details.

    The sprite-child's position is not set by AC. You can animate it as you are, but it will need to manually place it back at it's correct position again - either through script, or with another animation.

    As you're dealing with a child object, though, you need to update the sprite's local position - not world. Your script sets the Transform's position, but you need to instead set its localPosition:

    playerSprite.transform.localPosition = new Vector3(0, 0, 0);
    

    This should correctly reset the sprite's position to be at the character's origin - so you'll want to run this at the same time that the character is teleported to the Marker.

    It looks like your scenario is that your character is climbing out of a window. Is this how the scene begins? You may find that you can get a more seamless transition by having the character sprite start the animation away from their origin / root object - and have them animate towards 0,0,0 as the animation plays. This should do away with the need to reset the position through script.

    One other thing to mention, though, is that this situation might be a good case for the use of Timeline - Unity's sequencing tool.

    Using Timeline, you can layer up animation tracks to run in parallel - so you could have one track that plays the sprite animation (not controlling the position), and simultaneously run another track that only deals with the sprite's position.

  • Yes the player jumps out of the window.

    Ok, this is a good idea with the timeline Thanks for helping so quick. I have another nice guy which did a different approach. Sounds easy:

    Good there are several solutions. I will check on the timeline, too. But for the solution with the second player object is easier, I think.

    But maybe it gets very complex with all those markers, when the scene has many animations in it.

  • Indeed, there are a few approaches - though which one is best will depend on your situation.

    In the case that a scene begins with a character jumping out of the window, I would say the easiest/cleanest way would be to place the character at their final position, and then move their sprite child from the window to the ground through animation, so that they start offset but end up at their root position.

  • edited December 2021

    Thanks again...till the next one :-)
    :+1:

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.