Camera is follow sphere.
sphere rotation.
camera rotation too.
how can i fixed camera in sphere ?
my english is pretty basic. sorry about.
Camera is follow sphere.
sphere rotation.
camera rotation too.
how can i fixed camera in sphere ?
my english is pretty basic. sorry about.
Let me see if I understand. You have a sphere, and a camera either inside or outside sphere, you want to make it so that as the sphere moves and rotates the camera moves with the sphere, but you also wish for rotating the camera to move the camera’s position around the sphere, like a third-person camera, orbiting around a point? If so, create an empty and center it in the sphere. Parent the empty to the sphere so that when the sphere moves the empty follows. Then parent the camera to the empty. Instead of rotating the camera, rotate the empty to change where the camera is pointing at. If I understood wrong explain my misunderstanding.
Edit: So from what I can understand, you want the camera to follow the sphere, but the camera should not rotate with the sphere. To achieve this, we have the following:
You’ll need 3 things, The Camera, The Sphere, and an Empty object. Lay them out like so:
This means that the camera is parented to the Empty. Note that the empty is not parented to the sphere.
Next what we’ll do is instead of using parenting to have the empty move with the sphere, we’ll use a script. Add the following script to the Empty:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ParentLocation : MonoBehaviour
{
public GameObject parent;
public float offset = 5f;
void Update () {
Vector3 pos = parent.transform.position;
pos.y += offset;
this.transform.position = pos;
}
}
This script will constantly set the position of the empty to the location of the sphere, without the sphere’s rotation having any effect. In the Unity Inspector set the Sphere object to the parent field, and choose your offset, this will be what height above the center of the sphere the camera will rotate around.
Position the Empty at the sphere center and then move it up by your chosen offset, then position the camera where you’d like it to be in-game
If you wish to rotate the camera around, you rotate the Empty instead of the Camera. This is the result:
Do i use Ridbody or Terrain Collider If i want to player penetrating terrain ?