Tag Info

Hot answers tagged

5

As requested, one possible solution (with some flaws) is to use raycasting: Attaching a (C#) Script similar to this to the GameObject from which you want to check visibility would work: if(renderer.isVisible) //Check if Camera is turned towards the GameObject first { RaycastHit hit; // Calculate Ray direction Vector3 direction = ...


2

This indeed should be very simple, so I suspect you may have gotten some details wrong. The overall goal is to match up the center of the camera with the midpoint of the players. As you've found though, those values aren't immediately available to you, so you need to work them out. What you might have are (leaving out the Y axis stuff since we don't need ...


1

Depending on your exact needs, another possible solution would be to do a test render where you set different objects to different colors and then check for that color in the test render. However this would only be useful in pretty obscure situations; in the majority of situations I would use raycasting. I'm just dropping in this different answer for ...


1

In a first person camera, you can move the camera forward by adding the camera.direction values, scaled by speed * delta values, to the camera position. This moves the camera forward in the direction that the camera is facing. To move the camera forward on just the X and Z planes, you add camera.direction.x and camera.direction.z to the position. Create a ...



Only top voted, non community-wiki answers of a minimum length are eligible