In my scene I have 2 cubes with navigation static checked in the inspector and the navmesh has been baked.
https://i.stack.imgur.com/e9qXQ.png
You can see in this screenshot how when I put the camera inside the top cube, the navmesh has been baked underneath it, even though the cubes are perfectly aligned. I'm trying to avoid putting a navigation block under every static in the scene that has walkable areas above it. Is it not possible to have navmeshed surfaces that exclude the area underneath if it is unreachable?
Thanks.
I am pretty sure that if you do not have any links between the NavMeshArea you can just leave it like that, as the NavMeshAgents respect the area they are spawn/move to. But if you really want to get rid of it see below.
One thing you could do, is to add a NavMeshObstacle to the object and resize it, so that it fits the top area you want to get rid of. This would remove the area inside the cube.
Note that this is a workaround, as there is very likely another and better solution to the problem, but this solves the issue you are having very quickly.
Related
I would like to create a bunch of gameobjects to be used as spawn points and path finding targets, I’d like these to be visible on the scene view, even while the game is running, but not visible in the game. Seems like this should be a thing, but I’m failing to find it.
I’ve tried googling this, but all I find are people that are experiencing this behavior, but it undesired.
If you just want to see them, you can use OnDrawGizmos.
Inside this MonoBehaviour function, you can use Gizmos.DrawSphere(position, radius) to draw a sphere that can only appear in scene view. You just need to use the position of your GameObject as the position argument and you can draw as many spheres as you want. There are other shapes as well, see what fits your needs better.
Read the documentation for an example. Make sure to have your Gizmos activated in the scene mode, otherwise it doesn't appear.
Showing the general setup of the scene and where the sprite is
the sprite is "behind" the background but the Z-value should be correct
I have tried solutions such as changing the render mode of the canvas; the different options do not work and "World Space" turns the game view into the default background color. I could not figure this out after a day of reading up manuals/guides and looking at other questions. Thank you for helping me!
The issue is you are trying to use a SpriteRenderer on a Canvas object. Remove the SpriteRenderer and either use an Image or RawImage component instead.
Another note regarding UI that you will inevitably run into is unless specified otherwise, objects further down in a Canvas hierarchy will render on top of those above it.
I would also avoid changing the z-axis on all of your objects. Make Canvas groups that have different sorting layers to render groups on top of one another. Place objects in a specific order in the hierarchy to get the draw order you desire. Messing with the z-axis in a 2D scene can be a headache down the line and is not very modular. If you want to change sort order later, the specific z offset you set to each object will need to change.
I have a level made with pro builders and at that level there is an agent who attacks the player. The problem is that when i baked the navMeshSurface i did not include all the walkable surfaces. See the image below :-
I am now really frustrated with how to solve the problem, i tried nearly everything. I tried changing the layers and also tried placing other game objects over the area which are not baked. But, it did not work.
Please tell how can i include all the surfaces in the navMeshSurface.
make sure you have selected all the blocks, because if you didn't it will only bake the ones that are selected.
My current problem is that the cursor appears too far away from a button. You can see in the screenshot what I mean. Hovering over a button from the list lookes like this:
Question: What can I do so the cursor get closer to the button, because on the HoloLens you see the distance?
Looking somewhere else on the canvas except the buttons, the cursor gets closer:
--Edit--
I should mention that the scene has a scaled cube (the gray thing in the screenshot) and in front of that a world canvas (white thing), which contains the scrollview/list.
I saw the same behaviour for UI elements.
I can only provide you a workaround. It is a bit hacky but it works:
Go through all UI elements especially Text and Image and disable the option RayCast Target.
This makes the Cursor be sitting right on top of them ... but you will notice your Buttons are now non-responsive and you can not interact with them anymore.
This happens because the Physics system requires either a RayCastTarget or a Collider in order to fire it's pointer events like e.g. PointerEnter, PointerDown etc.
Therefore now add a BoxCollider (not BoxCollider2D!) to your Buttons and scale it to the correct size. It looks like you are using a VerticalLayoutGroup so you can simply correct the positioning of the BoxCollider by setting the RectTransform to centered once (the VerticalLayoutgroup will anyway re-enforce the Top-Left anchoring). In my case the BoxCollider needs with 0.8 and height 0.1 ... and for the z I choose 0.01 but it can be smaller if you whish
Hurray, now the buttons are interactable again and the Cursor only has it's usual distance + the half of the choosen z thikness of the BoxColliders.
Since the Background cube has it's own BoxCollider anyway we don't need to add further Colliders for the ScrollView and UI panels.
You might have to add some though for the ScrollBars as well if you need them!
As said this is more like a quick workaround and might not be a final solution since whenever a size of the Button or the ScrollRect is changed you have to rework those hardcoded BoxCollider dimesnions as well ...
I had similar issue on 3D objects. This could happen because the objects collider definition. I mean, you can import a render mesh but the mesh collider could be different (bigger, smaller, ...)
I hope this solves your problem ;)
I'm trying to do some Augmented Reality in Unity using the Vuforia plugin. I've managed to get everything working (I'm using a 3d model of a car), only the position of the car relative to the marker is wrong when I come to preview it (click the 'Play button at the top and watch through the computer's camera - is 'preview' the right name for this?).
It should be sitting on the the marker in the center, but instead it's floating above the marker and off to the side by quite a bit. The positioning is definitely right in the program itself, so I'm not sure why this isn't reflected in the preview.
Also: at the moment the car is simply an untextured grey object. I realise the textures are included in a subfolder, however I can't drag the entire car's folder (including the Textures subfolder) into the ImageTarget, only the .3ds file itself. Does anyone know how to apply the original textures to the car?
Thanks so much for your help in advance!
Ben
Well, to start answering your question about the drifting away part, you've probably got a Rigidbody attached to your Car? Well, if that's the case, then Go to the Inspector where the Rigidbody is and you'll see constraints.
To avoid it floating off, you might want to check Freeze Positions for whichever direction it needs. Probably Y axis.
Now, I'm not entirely sure if you're using Vector.AddForce to move your objects, but if you are then just check if your car can move if you've put all constraints on.
If you can't then in your code trying using Object.Rigidbody.SetActive(true) when you need it to start moving, and Object.Rigidbody.SetActive(false) when its done.
On the other hand, if you aren't using Vector.AddForce() then remove Rigidbody component if you've used it.
As for the material. If you've got the material in your folder that you've downloaded then just drag and drop it into Assets. Now sometimes your car may be one solid mesh, but some times it may be multiple meshes. So which ever the case. Drag the material from your Assets onto the Hierarchy panel over your car mesh/meshes and it should turn into that color.
Hope it helps. :)