How to calibrate the size and speed of 3d objects - unity3d

everyone
I am just starting with a new project in VR and have some problems.
I want to simulate a simple 3D-Ball like the real one in real world.
I am using OptiTrack to register my camera( 3d glasses) and Middle VR(free edition) to realize the 3D effect in 3D room. And also Unity for 3D models and programming with C#.
My Problem:
I have a real plastic ball and use it to compare with that 3D-Ball. If i go to the real ball in (real world) it will be bigger and if i go away from it, it will be smaller visually.
The 3d ball has the same diameter as the real one and stand at the same position. But if i go to ihm with 3d glasses it will be (quicker) bigger than the one in real world and if i go away from it, it will quick smaller than the real one...
Can anyone explain to me, how to solve the problem, what should i do. I need your help.
Thank you and have a nice day.
Carvin.

Get the size right inside unity. 1 unit in unity is 1 meter in real life.
Also play with the field of view of your maincamera in unity to get the desired result

Related

Voxel Water in unity engine

I am trying to create a voxel style RPG like the one shown in Cube world. And I am trying to get an efficient low-GPU-intensive way to create Voxel water; like the water shown in these
https://www.youtube.com/watch?v=ZCFIchEZk2s
https://www.youtube.com/watch?v=qJa2w-7edKA
However instead of Blender in unity. I feel it would be good to use a procedual shader (for foam, and waves, and adapting to players jumping in it) of somesort to be efficient for my uses (Ocean, rivers, lakes etc...). though I cannot think of a way to create this kind of shader. I have attempted to throw toghether a shader however I am not the most experienced in the non-programming field.
Any help would be greatly appreciated. Thanks!
A shader will not be a good idea for water simulation. I would recommend you use cellular automata to get these water voxel some realistic movement.
Cellular automata works when you divide your world into a grid of cells and every update you change the cell state or position depending on its cell neighbours. There are some good examples of this in games like Conway's game of life and Noita:
Conway's game of life Wiki
Noita trailer
But I will guess that you are going for more of a 3D
style. There is this voxel game which does water simulations very nice:
John Lin's voxel engine

2D Sprites in Isometric 3D Unity Project

The project works under a isometric orthographic camera, in a 3d space using 2d sprites.
What we are using are billboarding sprites into 3D colliders to archieve the 3d feeling.
The problem is that we don't really believe the way we are doing it it's the most optimal. We are also having problems introducing high areas, because we need to reply the sprite form in isometric perspective as colliders.
Because we are using 3D world, the tilemaps tools conflicts with the other vertical sprites.
We can not use a entire 2d floor billboarding sprite because that suposes to have a huge vertical sprite in front of the camera, so we can not display the others.
We are just researching for a solution before to change to a 2D world.
If you plan on sticking with isometric in 3D, get rid of the tilemaps entirely. They are just going to give you a headache and make your game lag itself to death. If you want to convert to entirely 2D isometric, you can stick with them as they would work fine. Now, a few comparisons between the 2D and 3D approaches, and how best to approach them. This is a jumbled list of drawbacks/advantages to each type, so it's more of a ramble after this point than an answer, but I couldn't be more specific without knowing more about your project's overall requirements and specifications.
Unity recently added Isometric Tilemapping as a dedicated feature. So, if you choose to fake it with 2D, your life will be a lot easier.
Controls are a lot easier in 3D, as the physics won't ever have to be
faked.
3D allows foreground objects to automatically cover up background
objects without having to add an arbitrary system to achieve the same
effect.
2D is fundamentally faster than 3D, and if you're aiming for mobile,
that's going to be very important to your project's success.
3D allows you to rotate your camera if you design it right. (Check out Don't Starve Together for an example of this design).

Feasibilty/efficieny of using 3D models for a 2D game

I've been using Unity3D for a while now and I've also had experience coding 2D games using LibGdx.
In the past, I used to get my sprites off the net or make my own however that wasn't really the best way to do things since I'm more of a programmer and would sometimes need very specific things and so I've started to learn blender and I'm actually enjoying it atm.
What I want to know is how much of an overhead is it if you're using 3D models for a 2D game? Especially if you want to port it to mobile?
The overhead is significant for rendering since with a basic sprite, you have 6 vertices (2 tris to make a quad) while a 3d model can have hundreds of thousands of vertices.
The advantage on the other hand is that animations are made of sprites, so your texture amount and size may increase. In 3D, an animation is a text file so fairly light.
The physics is simplified in 2D since you can do surface collision while 3D requires volume collision and obviously checking an extra dimension is more expensive.
There are probably other considerations but those are the first coming in mind.
Now, the choice of 3D over 2D should be simply based on what you are trying to achieve. Side scrolling games like Angry Birds do not need 3D. Games like Taichi Panda are better with 3D despite being a 2D game (only x and z camera movement I think).
A FPS game should only be done in 3D or it will look like Duke Nukem.

AR Overlay Accuracy in Google Project Tango

I am experimenting with overlaying augmented reality objects over a pass-through image from the rear camera in Unity.
Has anyone experimented with overlaying objects with accurate tracking? I've tweaked the movement scale to get somewhat decent results but rotation is still not accurate and drift is a big issue.
I've had good luck with the augmented reality sample that ships with the latest tango. in my experience it does work the way you speculated where if you add items to the unity scene they are synced to motion detected by the device.
I believe the tracking and syncing function have improved since you asked this question originally because I've noticed an improvement since I got my tango devkit a month or so ago. there was an update a week or so later, with an immediate improvement.
I have found that some scenes track better than others, it seems to help for there to be additional scenery for it to track. in my workspace, a fairly cluttered apartment, it tracks well but in the neighboring identical apartment unit which is currently vacant and empty, it does not track as well. that could also be a product of the blinds hanging up in my unit that are not hanging up in the vacant unit, filtering out additional infrared.
I'm experimenting with placing 3D objects over the real time input from the Tango color camera.
One problem here is that the hardware color camera 'point' in a (strange) direction. I wasn't able to get the direction vector from the api until now. Your virtual camera for rendering the scene needs this rotation to render 3D objects properly.
There are augmented reality examples of Tango's Unity plugin:
https://developers.google.com/tango/apis/unity/unity-simple-ar
They solve this problem with a matrix that rotates the 3d camera.
It can be found in the Unity script "TangoARPoseController" (C#) that, when attached to a unity camera, rotates it so that it looks at the scene in the right direction. The matrix is obtained in the method "SetCameraExtrinsics" of that script.
Unfortunately, when I apply the matrix to my unity scene it does not produce a perfect overlay (actually it's quiet bad). But I have other sources of position input which may be the problem here.
However, until now I'm not sure if the matrix used in the examples is good enough for accurate ar overlays. Maybe it is just suitable for demonstration purposes. But it should be a good starting point for further investigation.
Are we talking about displaying the 'webcam' in the background as opposed to a skybox ?
Take a look at my GhostHunter repo. It includes a shader and a script for displaying the rear facing camera 'behind' the gameplay objects (like the skybox). It should be useable with Tango and it is better than the 'display on a mesh' technique I`ve seen others used.
https://github.com/NVentimiglia/Augmented-Reality-Ghost-Hunter

Trouble getting correct height of joint positions in Unity Xbox

I am using Xbox-Unity and am trying to make a Kinect game. I need to be able to know when a player's foot is in the air and when it comes back down on the ground. I thought that this would be as simple as tracking the Joint Positions but the foot's Y changes based on the proximity to the Kinect Camera (Taking the foot joint position from Kinect). If I lifted my left foot up far away from the camera, it's Y would be high(let's say 10). If it were to land close to the camera, the Y would be low(let's say -20). What I had hoped was that I could just say 0 is the floor and have an easy time knowing when a foot was in the air and when it was on the ground. Does anybody have any ideas on how I can correctly tell when a foot is grounded?(everything I can think of so far had at least one exception that would make the gameplay broken)
Edit: Used a point to plane equation but no matter what I do, the distance to floor is always different based on my proximity to the camera.
One possibility would be to compare it to the other foot.. if one is higher than the other, chances are they're standing on the other foot. If you're looking to detect jumps, you should be able to find a sudden change in the y position of both feet.
There's also the Floor Clipping Plane, but that involves some more complicated math from what I've seen. Check out the Kinect programming guide, which is super old but I think should still be relevant here. The section "Floor Determination" is what you're after.