Stop display through object despite transparent material? - unity3d

This is very difficult to describe, but I feel like it should be possible to do.
Essentially, this is where I am at:
Since the Earth's material has outer normals, its own material is not displayed on the other side of the globe. However, due to the transparency of the material, I see the markers that exist on the other side of the globe.
How can I stop things from displaying through the material? The background is the skybox and is the only thing that I would like to show through the transparency.
Any help or advice is appreciated.

it's a little tricky to do this:
the only way is:
turn OFF each green skyscraper, when, it is at the "back".
Let's say your world is simply centered on 000.
In that case, if you think about it it is this simple...
If z>0f, then you want the green skyscraper to be invisible. If it is z<0f you want it to appear normally.
Since this is Unity you must work in an agent-like manner. So actually it's this simple. Make a script (pseudocode)
Class HideMeIfAwayFromCamera
{
Update()
{
if ( z > 0f ) renderer.enabled = true;
else renderer.enabled = false;
}
}
That's probably your simplest and best solution here. in any event, I would try that first. Let's hear how it works for you.
Consider that you may want to make the on/off point a little ahead or behind the half-way plane, try it.
Note that another approach is. You kind of need to use a cutout shader; use a different layer altogether for the skyscrapers; and use yet another layer for any skyscrapers who's base is beyond the horizon; in this way you can let it show the "tops" of any skyscrapers that are "just behind" the horizon but hide the bases. It does seem way too complicated though. I think the best result will be just turning off the rear ones, as shown above.
(Note too that it's not "physical". If the globe is transparent: you SHOULD be able to see the skyscrapers at the back. So you'd have to try some things to see what feels good.)

Related

Having issues with animations of objects that come from a prefab

So let me preface this that, i am very new to unity this is my first week actually lol and i couldnt exactly find anything that would answer my question.
Anyways, i have this like thwomp object that has 3 animation states crush, reset, and wait. and it goes up and down as you would see it normally just on a timer because of the wait. it is done by adding the position property and then moving the y up and down. pretty simple i think, couldnt think of anything better. it works perfectly just like i want it too.
but when i made it a prefab and try to make more of them, the animation for the copies have the same x and y as the original. so like even though i can change the base like default positioning of them whenever the game starts and the animation plays they just perfectly overlap with the first original one that the prefab was made with. when i try to change the x coordinate on the copies animation it updates the x coordinates for all them. this happens even when i delete the prefab and just manually make copies with ctrl + d as well (im not sure if this any different?) . i assume this is because they all share the same 3 animations so when you change the animation it changes it for all them and that makes sense.
but i really dont want to make 3 seperate animations for each replica thwomp i make, i feel like there definitely has to be a better way. my original thought of how it would be was they would share the same animation, but like within the object its self the animation values like the position are exclusive to the object so they could differ inbetween each one.
ill include a link a picture to like further convey what i have going on here so its easier to understand. https://imgur.com/a/78q6VCI
You want to change the localPosition not the world position. This thread has a little discussion about it but basically you need to use the x, y, z you get from the Animator as an offset to localPosition.
Pseudo code:
transform.localPosition.y += animators position.y
https://forum.unity.com/threads/playing-animation-local-to-position-in-unity.53832/#post-489101
Special note: Using an animator is pretty heavy. For simple stuff like this I would suggest just scripting it.

Unity 2D: How to make tiles merge with equal textured neighbors?

Let me show you what I mean:
Suppose we have a puzzle game with colored square tiles/blocks falling, and they stack like this:
My question is, instead of each tile/block sprite stay visually separated from others, what technique can be used to make each tile aware of their neighbors when they stop falling, and change its sprite (and neighbors) to become visually "glued" with them, like this:
I cant seem to come up with a simple and efficient solution for this, any ideas?
Here are two options that come to mind:
Easier approach - Use a tilemap, each item should have variants for every color and connection in every direction
Harder approach - Build your meshes in realtime and calculate the actual sizes yourself. I think this option could be more robust, but it's much more complex to do (especially if you haven't done something of the sort in the past)

Unity3D: How to make a glowing gradient sphere?

So I need a glowing sphere with a halo of light, which casts light on a near objects. Also, as you see on the image, sphere must have a gradient.
I'm using 2 spheres and point of light at the moment. And I really don't like the results:
There is no gradient at all
I need to use second Point Light to cast light to near objects
So... is there any ideas?
I think you have two needs,
(1) the "actual" light which casts a light on nearby objects.
(So, I mean that is literally a UnityEngine.Light http://docs.unity3d.com/ScriptReference/Light.html )
(2) Separately, you need (basically) a "glowing orb" that looks like the white and yellow thing in your image.
These two things are completely separate.
You should indeed do them separately.
Now regarding "2" how to make a glow, that's called a "bloom". There is a lot to look in to but this will probably do it for you:
http://answers.unity3d.com/questions/914945/what-replaces-the-glow-effect-in-unity-5.html
Note that getting a good glow is not that easy.
Here's a really great asset, that's actually free for goodness sake,
https://www.assetstore.unity3d.com/en/#!/content/28044
you should surely get that to experiment with at first. There are other well-known assets as well, like https://www.assetstore.unity3d.com/en/#!/content/8238
Be sure to google for many QA on the glow topic.

How can I make part of a mesh transparent?

Is it possible to make some % of my mesh transparent?
For example, imagine I have a mesh that is a house. At first the mesh is transparent. As a person clicks on the house, it becomes opaque along the Y-axis so it looks like it's being built up.
Any ideas how to approach this problem?
"a house. At first the mesh is transparent. As a person clicks on the house, it becomes opaque along the Y-axis so it looks like it's being built up"
Literally in answer to your question, in general:
I would approach this by making a shader which was sensitive to the global Y value of the point in question. It would use that value, over time, to decide on alpha at a given point.
alternately
Imagine a second texture of the house, call it GUIDE, which is: imagine a monochrome house: at the ground it is black and it slowly becomes pure white at the tops. Additionally you could color it any way you want, for example, the window frames and quoining could be black and so on. Now, the shader would use the GUIDE texture as a key, to know at what time, that area, should become transparent.
That would actually look quite incredible and offer amazing control. You could fade in different parts in whatever order you wish.
It would be beyond the scope of an answer here to actually engineer this. But I believe the key here is, unfortunately for what you describe that is really all done in the shader, I'd say.
Note that if you just want "a clean hole", look in to approaches using a depth mask shader And indeed https://www.youtube.com/watch?v=s3RKGAj9Uzk
for 2D consider this, http://answers.unity3d.com/questions/449034/see-through-hole-via-shaders-on-a-2d-plane.html
in other cases you may literally want to cut a sharp hole in the mesh which is a "whole" different technology. https://gamedev.stackexchange.com/questions/72978/shader-that-cuts-hole-through-all-geometry
if you want this effect http://answers.unity3d.com/questions/622089/how-can-i-render-a-semi-transparent-texture-with-a.html (see mario image) that's totally different again - it's nothing more than a gray image with a hole!

Matlab: Track point on object in video

I would like to track (if that is the right word for this) the movement of a point on an object and return the co-ordinates for the point in each frame to arrays for plotting. How would you go about doing this?
The point on the video is a certain color and so my first effort was to eliminate all other colors and change the part I wish to follow to black and everything else to white. Doing this left me with some areas in the background which are the same color but I wish to ignore them and just focus on the moving point. I do not know where to even begin with this or if I've even been trying to do the right thing so far?
Any help would be greatly appreciated! :)
Try searching for terms like 'tracking', 'morphological', 'computer vision', 'matlab'
Here's a project that I found that will probably get you started.
http://www.mathworks.com/matlabcentral/fileexchange/28757-tracking-red-color-objects-using-matlab
if your object of interests is of a certain specific color. You can always apply a color-filter. To give you a bit of a background, i was trying to track not a point on an object, but a moving object in one of the videos i have. (it was a ping-pong video and my goal was to track the ping-pong ball). My algorithm was simple and fast (as i did not want any of my filters to induce heavy computations at one single frame). The basic idea was to apply a color filter. Similar to other shape filters, if your target is of high similarity to the filter, the response will be distinctive enough for you to notice. In other words, if you minus two objects that are extremely similar, you will get 0, otherwise, it will be far greater than 0.

Categories