I am trying to create a Line Renderer that renders a line between several objects augmented with Vuforia image targets.
I understand that the Line Renderer component has the "Alignment" field which can be set to either "View" or "Transform Z". For my project, I need the rendered lines to always face the camera, so I have that field set to View. Here is a picture of the component:
However, in both the Unity Editor preview and on my deployed Android application, the line rotates along with the objects (for example, if I move or rotate the image target). The ARCamera is already tagged as MainCamera, so it should be recognized as the camera.
Once I noticed this, to test if the field was being overwritten somehow, I added the line lr.alignment = LineAlignment.View; to both a start function at the beginning of the application, and to an update function, to make sure it is always set to View, but that did not change anything.
Is it possible for the Line Renderer to always face an ARCamera? Is there a step I am missing?
Here is a picture of the issue, where you can see that two of the lines are rotated to their side (the top line between the blue and green spheres is hardly visible).
Related
I have a first person controller and currently if I walk into a slightly transparent object, it disappears until I walk out of it.
I have a 'water' cube object that is very light blue and transparent, and when I move my camera into third person view then enter the water, my screen turns light blue which is good. In first person mode (which is what I'm trying to figure out), the cube disappears and my screen color remains the same.
I know it has something to do with my camera but even after going through all the features on unity docs and changing a few settings in the inspector, it all remains the same.
Like mentioned in the comments your cube is not visible because the backside of its faces is being culled, meaning they are not rendered. This is not a camera setting but a property of the shader your water cubes material is using.
You could create get a duplicate of the shader your are using where you add Cull Off to change this.
Read about it here.
If you want to go that route you need the source files for your shader. Assuming it is one of the Unity Built in shaders you can get them from the Unity Download archive here for your Unity version.
Clipping the camera trough objects is rarely a desired and you should look at a different way of achieving your effect like using a post-processing volume because the "water" would still be a cube and be drawn behind everything in front of its faces.
For example in a FPS type game this would result in the gun not changing color.
My game has this system where the player is rewarded with hearts.
Whenever a heart appears, it's supposed to appear with a value on it (say, +5). I did some googling and everything said I need to attach a canvas to the sprite and then a text component to the canvas. However, this doesn't seem to do anything.
You just need the following structure
Sample Image settings: (Here you'll want to replace the "Source Image" with your heart sprite)
Sample Text settings: (Although I recommend using the TextMeshPro component instead)
Result:
I am working on a small game where I only want to draw the objects (mesh) when it is inside an invicible box. I have gotten the clipping to work so that the mesh is only rendered inside the box (using the solution mentioned here: https://answers.unity.com/questions/1875660/urp-render-only-whats-inside-a-cube.html
The only annoyance now is that even when the mesh is clipped, the SSAO is still being rendered as you can see in the following image (in the red box):
I assume it is because the object is still contributing to the depth normals - but I am unable to find more information about this - or even if this is the actual issue.
Do any of you have a suggestion for how to prevent this from happening?
I am using Unity 2021.2.8f and URP v12.1.3 btw
The Postprocessing effect SSAO is applied to all layers seen (not culled) by your main camera. Try to put the object on a different layer and ignore it on your main camera.
You could also integrate an additional forward renderer (+ new camera) to your project, which does not use the SSAO effect and takes care of your object.
Does any know or can possibly point me to some instructions or a github repository on how I can create a script where I have an object and in GoogleVr (Cardboard) if I was to gaze over an object, a tooltip would appear?
If anyone is familiar, in the Cardboard Demos under Under Arctic Journey > Learn, when you click on the fox, a tooltip appears to showcase that item along with like a brief description on it. I want to have something similar (maybe even the same thing) except just having a gaze over will automatically show it. Is this possible?
I want to have this done on multiple objects in my project so I want it created so I can easily substitute out text and whatnot.
Have a script with a reference to a World Space Canvas (WSC). The WSC will be your tooltip and be activated when you hover over the object and disabled when you don't.
You can set images and texts of the WSC through the inspector or through code if you make a reference to them.
The script should also always have its rotation set to face the player.
You can use the SetActive(bool) method to show or hide the WSC.
The UI system makes it easy to create UI that is positioned in the world among other 2D or 3D objects in the Scene.
Start by creating a UI element (such as an Image) if you don’t already have one in your scene by using GameObject > UI > Image. This will also create a Canvas for you.
Set the Canvas to World Space
Select your Canvas and change the Render Mode to World Space.
Now your Canvas is already positioned in the World and can be seen by all cameras if they are pointed at it, but it is probably huge compared to other objects in your Scene. We’ll get back to that.
https://docs.unity3d.com/Manual/HOWTO-UIWorldSpace.html
I'm newbie in Unity & I wanted to add a water to my scene but the water that I added looks purple and I got two error messages as well in my console which says:
Material Does Not Have A Color Property
So how to fix this issue ? There must be a problem with my shader texture however the material has the write texture.. Print Screens Are Below:
That's the graphics card's way of telling you it doesn't know which shader to apply your object.
Click on a mesh that is pink, and the material property will be set to none or missing. You'll need to remap the materials in your project to your pink objects, or drag the textures back onto your objects again.
You are seeing this pink color because a shader is missing or is not properly selected.
I'm sure the following is the error you'd encounter in the inspector:
This is how it should look if everything is correct:
I selected the shader in the file browser so you can check the location yourself.
Resolving the issue
The first thing you could try to resolve this issue is open the shader tab in the inspector and search the "Shader" dropdown menu for the water shader:
If you can't find it there the only option is to reimport the assetpack.
Or copy this shader from another project where you still have it.