How to create third person camera with lock on ability. Similar to Rocket League - Unity - unity3d

I currently have a camera setup with the camera being the child of the car so that the camera is a constantly moving with the car. I have the ball set as the target and the camera is locked onto the ball using transform.LookAt(target.transform);. However, when the car turns, it leaves the cameras sight and the camera continues to look at the target object. An example of the problem I'm having can be found here:
And here:
The camera moves in between the car and the target object, but I need some sort of rotation to keep the car between the camera and the target object. Thanks in advance for your help.

Related

Unity3d: How to map real-world coordinates to scene coordinates?

I have a physical (real-world) camera and a Unity3d Scene. I want to map the physical camera coordinate system to the virtual scene, 1:1.
For example, imagine the physical camera is pointed at the sky and an aircraft flies overhead. I want to have the physical aircraft appear in my virtual environment, at the correct location. I can get the ADS-B data (which describes position and altitude of the aircraft) and a generic 3D aircraft model. I can import that 3D aircraft model into my scene, but how do I know where to put it and at which height in the scene? And when I move the physical camera, I want the virtual camera to move in the same way.
Put another way, if you wanted to recreate the Earth (ignoring all textures, lighting, etc.) in Unity3D, how would you ensure that objects in the physical world appear in the same location as in your virtual Earth?
How can I do this?
Unity has a built-in LocationService class to determine your location on the globe. Then there is Input.gyro, which can be used to determine where approximately you are pointing. Use this information and the flight transponder data to compute your position relative to the aircraft. Obviously, this will be wildly inaccurate. But, as others suggested, you can gain additional accuracy by setting your virtual camera up as a Unity physical camera and matching it up with your real-world camera. From your camera footage, extract the clip space position of the aircraft using some kind of image recognition method (i.e. a ComputeShader retrieving the location of a small dark spot) and then use Camera.ScreenPointToRay of that position to get a vector towards where the airplane should be in the scene. Using this, correct your virtual user position in the 3D scene, such that the ray lines up with the vector from your virtual camera to the virtual aircraft.
I think what you want to do is to do 1:1 map of real world in your unity scene. For that you will need to read this documentation. Basically 1 unit in unity is 1 meter. To make dimensions of 3D objects 1:1 to real life dimensions you will need to resize/change scale of those objects manually. Good Luck with that!
If you want a virtual camera that is just like your physical one then there's toggle in "camera" component called "physical camera". There you can set it's sensor data and all that kind of stuff. If it's not it, I don't know.

Unity switching to third camera turns game objects invisible

I'm having a problem with some of my game objects (walls of rooms) turning invisible when I switch from my first person camera to my third person camera. The layer that the walls is on is NOT selected by either camera's culling mask. The camera settings should all match because I created the third person camera by duplicating the first person camera and then moving it to a new position. The game starts with the first person camera active and the third person camera inactive.
Does anyone have suggestions for what might be causing this problem?

Hotspot visibility in virtual tour for VR headset

I am creating virtual tour for VR headset in Unity - I create sphere and fill it with panoramic photo as material. For every sphere I create hotspots to switch to another scene after looking at it. I was testing it with Oculus Rift DK2. The sphere was visible, but the hotspots were visible all - for all scenes, but I need to see just hotspot for the current scene [1]. Anyone has idea hot to do it? Maybe something with transparency of spheres, but I saw just hotspots, not other spheres, so I think that sphere transparency is ok.
[https://i.imgur.com/F3S9C8w.png] - here you see also other scenes, in VR headset there are only hotspots, the spheres are not visible. This is right, but about hotspots - I need to see just that one for actual sphere, not all.
I was creating virtual tour according to this tutorial: https://tutorialsforvr.com/creating-virtual-tour-app-in-vr-using-unity/ ; you can see there also script for hotspots.
Thank you for all comments.
Make in your script public GameObject scena1Sphere, scena2Sphere, scena3Sphere;. And connect that game object from hierachy to sript fields. Then you can type:
//for first scene
scena1Sphere.SetActive(true);
scena2Sphere.SetActive(false);
scena3Sphere.SetActive(false);
//then when you switch to scene 2
scena1Sphere.SetActive(false);
scena2Sphere.SetActive(true);
scena3Sphere.SetActive(false);
// and for third scene
scena1Sphere.SetActive(false);
scena2Sphere.SetActive(false);
scena3Sphere.SetActive(true);

From 360 video to Virtual world

IS it possible to convert a 360 video into a VR World ? Let's say i take a 360 video of my room, convert it into a 360 VR world and user with a headset can click on a chair in my room to know the details ?
One way to accomplish this is when you put the 360 degree picture or video of your room, place GameObjects in the line of sight from the camera towards the object outside the sphere on which the photo/ video is playing. Then attach all the interactions you want on those game objects so that when your raycaster interact with the GameObjects your desired functions get done, like for example the details appear on another canvas which is just above your chair. Look at the attached picture, I've placed the red sphere which is my gameObject used as an event trigger to perform a change scene function when a user looks at an object in the video which is exactly in the line of sight of camera to red sphere.

Unity 3D with Vuforia AR: Adding a Gameobject to ARCamera View

I am using Unity3D with extension of Vuforia. I am working on Cylindrical targets. When ARCamera detects the image and starts the augmentation, I want to show my GameObject (.fbx file, imported into the Meshes folder and created a Prefab out of it) on the screen.
I am working in Unity C#.
I attached a script to the GameObject and initialized it DefaultTrackableEventHandler Script. When I run it in Unity and the camera starts, I don't see my object in the Game View. Whereas in Screen View, I see that bottle (Prefab) rotating.
make sure the camera, or the focal point has your object in sight, when i tried vuforia, rotate your card slowly 360° to see if you can see the object, also your object could be far above what you expect, I would recommend very long expanded cubes in the 3 axis, to get the reference in the augmented world, then move from there