CSS3 Translate % Units? - css-transforms

Here is what I want to do
a. I have a ball whose top edge is located 50% below the top of its container
b. I want to apply a translation that moves it do it sits on the floor of the contaienr
Here is what I tried
.ball
{
position:absolute;
left:25%;
top:50%;
height:80px;
width:80px;
-webkit-animation:fall 3.4s normal forwards ease-in-out;
}
#-webkit-keyframes fall
{
0%{-webkit-transform:translateY(0%);}
100%{-webkit-transform:translateY(100%);}
}
The end result I see is quite unexpected - measuring the extent of the drop with the PicPick pixel ruler indicates a drop of 80px i.e. 100% corresponds to the height of the ball. By using pixel units I can get the ball to drop through the precise pixel distance that I indicate but that is not quite what I need to do.
I suspect that I haven't quite fully understood the issues involved here. I'd much appreciate any help.

Simple answer - that is in fact the right behavior. If you want to use relative units in translate transforms consider using viewport length units instead.

Related

Dynamically control Unity Cinemachine vCams Blends: HOW?

I can't find how to constantly dynamically blend between 3 cameras (I call them middle, upper & lower) based on the rate and height of the hero, constantly.
When following the hero, the middle vCam is the main/base one, I'd like to proportionally blend through upper and lower vCams based on the height of the hero.
The player/hero can move rapidly between heights, so the blend should be weighted with eases. Which is a natural part of Cinemachine blends. And works. But it's like a switch, to me, at my current understanding of Cinemachine blends, rather than a constant dynamic blending based on height.
You may consider removing the upper and lower camera and do your own "Manual blending" with only the middle camera. Recently I've been using Cinemachine and I do something similar of what your desired result is.
Since I don't exactly know how do you want your camera to behave, I show you some of my manual blending I've done, explained:
//Camera Direction
//If I´m not in ground, and I've been on the air for a specific time
if (!onGround && timeSinceLastJump > cameraDelay)
{
//Moves the offset of the camera down to the maximum allowed y offset (In your case it would be where the lower camera is)
if (vcam.GetCinemachineComponent<CinemachineTransposer>().m_FollowOffset.y >= maxYOffset)
vcam.GetCinemachineComponent<CinemachineTransposer>().m_FollowOffset.y -= offsetYSensivity;
//It also zooms out up to a specified level
if (vcam.m_Lens.OrthographicSize < maxFOV)
vcam.m_Lens.OrthographicSize += camSensivity;
}
else
{
//Same but upwards
if (vcam.GetCinemachineComponent<CinemachineTransposer>().m_FollowOffset.y <= minYOffset)
vcam.GetCinemachineComponent<CinemachineTransposer>().m_FollowOffset.y += offsetYSensivity;
//Same but zooming in
if (vcam.m_Lens.OrthographicSize > minFOV)
vcam.m_Lens.OrthographicSize -= camSensivity;
}
This way you can use your player height in the conditions, at the cost of having to design well the camera logic.
Maybe this helps you in some way to do what you want.
From what I remember, you can define the blend style in the Cinemachine blend options. From the description, it seems that it is set to "Cut" when you probably want something similar to EaseIn/EaseOut. It even allows you to define your own custom blend between cameras if the default options do not work for you.
Take a look at the documentation for more details.

Weird Lines 3D Unity

I'm working on a project, using unity 5.4.
In this projects blocks are stacked next to eachother.
However there appear some annoying weird lines. Also on android these
line occur more often than on PC.
For illustration purposes I added an image and video.
Please zoom in on the picture to see, the line I'm speaking of, clearly.
Could anyone please provide a solution to get red of this nuissance.
Thanks in advance.
Literature:
Block alignment code snippet:
for (int x = 0; x < xSize; x++)
for (int z = 0; z < zSize; z++)
{
Vector3 pos = new Vector3(x, -layerDepth, z);
InstantiateBlock(pos);
}
Video link: https://youtu.be/5wN1Wn51d_Y
You have object seams!
This occurs when there is a physical or perceived gap between objects.
There are multiple causes for this.
1. Floating Point Imprecision
This could be because you are setting the position of the cubes to int's but they have floating point dimensions. The symptom for this is usually no white seams when the camera is close to the objects, and then they gradually appear as you get further away due to floating point imprecision. More.
Most of these blocks appear to line up exactly, from most camera positions. But from the occasional unfortunate position, the exact value for A's position plus its vertex at (0.5,0.5,-0.5) might be slightly different to object B's position plus its vertex at (-0.5,0.5,-0.5) . The result is that Unity shows a tiny gap, within which you can see the shadowed side of cube A.
If you consider the following on paper 3 == 1/3 * 3 this is mathematically correct, however using floats, 1/3 == 0.333333... and subsequently 3 * 0.333333... == 0.999999... BINGO! random gap between objects!
So how to solve? Use floats to calculate the positions of your objects. new vector3(1,1,1); should be new vector3(1f,1f,1f); - for example. For further reading on this try this SOP.
2. Texture Wrap-mode
If you are using textures on your objects, try changing the Wrap-Mode of your texture from wrap to clamp, or try upping the texture padding.
3. Shadow Acne - (Lighting and Shadow artifacts)
This is the arbitrary patterns of pixels in shadow when they should really be lit or NOT lit.
To prevent shadow acne, a Bias value can be added to the distance in the shadow map to ensure that pixels on the borderline definitely pass the comparison as they should, or to ensure that while rendering into the shadow map. source.
In Unity... go to your light source and then increase the Shadow Type > shadow Bias I would suggest doubling the default value of 0.05 and then continue so until fixed. You don't want to crank this value to max because...
Do not set the Bias value too high, because areas around a shadow near the GameObject casting it are sometimes falsely illuminated. This results in a disconnected shadow, making the GameObject look as if it is flying above the ground.
Are you using different blocks that you put against eachother? Your problem sounds like the blocks are not completely against eachother which causes you to see the side of the next block (this explains the camera Y changing: you might see the side better from higher up). That side will have different lighting and appear as a different/lighter colour. To check if this is the problem, try overlapping them slightly manually in the editor and see if the problem still occurs.
Making the blocks kinematic solves that. The issue is the rigid bodies bumping up against one another.

SpriteKit - Getting The Weight Of A SKSpriteNode

I have an app with large boxes falling on top of the small red box. I would like to know when the small red block reaches a certain weight (X blocks are resting on top of it). I couldn't find a weight property for the red block. Any suggestions?
EDIT: Just to clarify. The boxes falling from the top will be random sizes, and falling from random positions. So there isn't really a way to keeping track of what landed on top of the red block. I need some way to measure the downward force being applied to the red block
You can calculate the weight for each node the following way and then add them together.
redBox.PhysicsBody?.mass

Find angle face under mouse pointer in Unity 3d

I have a projector component and I need to find the angle that projected texture falls at to exclude the projecting on vertical faces.
My projector is under the mouse pointer and works ok when it is over an horizontal face:
I would like the projector to switch off on vertical faces to avoid this bad effect:
If possible, I would like to do it in the shader code to avoid the vertical projected image even if the cursor is located on the corners of an horizontal face and a part "goes out" on vertical face.
I found this solution in C#:
if (Physics.Raycast(MouseRay,out hitInfo)){
if(hitInfo.normal.y>0) {
// draw
} else {
// not draw
}
}
But only it works on curved surfaces and not, for example, on the face cubes.
How can I do this properly?
Normally they would use an image on a quad using TGA transparency, which rotates itself to the face that the middle of the object is aligned to, using ray to find the vertex and making it's absolute normal.
Other ways of doing it would be quite tricky, perhaps using decals... If you did it using a shader, it would take so much time... it's a case of problem solving not being ordered in order of importance for fast development. Technically you can project a volumetric texture on top of whatever object you are using... that way you can add your barred circle projected from a point in space towards the object, as a mathematical formula, it takes a while to do, check out volumetric textures, i have written some and in your case it needs the mouse pos sent to texture and maths to add transparent zone and red zone to texture. takes all day.
It's fine to have a flat circle that flips around when you change the pointer onto a different face, it will just look like a physical card and it's much easier to code, 10 minutes instead of many hours.

In SketchUp how do I create a solid half sphere/dome? I keep getting a hole in the top

I'm not sure if SO is the best site for this question, but I saw some other sketch-up tags...
I've found a bunch of tutorials that show how to draw a sphere. Here's one for example. However, whenever I try it I get a half sphere with a hole in the top:
What am I doing wrong?
To Clarify: The half sphere needs to have a radius of 7/32". I noticed that when I use this measurement (and other smaller ones) I get the problem. I tried it without specifying 7/32" and drew a somewhat bigger second circle and it worked:
How can I get a solid half sphere that has a radius of 7/32"?
I'll leave this for others' reference. I ended up drawing at 4X and then used the scale tool to shrink it down to 25% after the fact. Maybe SU doesn't do so well with smaller sizes.