“Camera Suivre l'unité du joueur” Réponses codées

Camera Suivre

public Transform player;

    public Vector3 offset;

    void LateUpdate()
    {
        transform.position = player.position + offset;
    }
Obnoxious Ocelot

Camera Suivre le joueur Unity Smooth

// CAMERA FOLLOW PLAYER - IN FIXEDUPDATE

Vector3.SmoothDamp(cam.position, transform.position + cameraOffset, ref cameraVelocity, CameraFollowSmoothTime);
cam.position = cam.position + cameraVelocity * Time.deltaTime;
Tough Tern

C # Unity Camera Suivre

public Transform Target; // Drag the object that will be followed in the inspector.
public Transform Camera; // Drag the camera object in the inspector.
Vector3 tempVec3 = new Vector3(); // Temporary vector 3.

void LateUpdate()
{
  	// If the target is active in the scene, set the x camera position to target.
    if (Target != null)
    {
        tempVec3.x = Target.position.x;
        tempVec3.y = this.transform.position.y;
        tempVec3.z = this.transform.position.z;
        this.transform.position = tempVec3;
    }
  	// If target is not active in the scene, set the x camera position to itself.
    else if (Target == null)
    {
        tempVec3.x = Camera.position.x;
        tempVec3.y = Camera.transform.position.y;
        tempVec3.z = Camera.transform.position.z;
        Camera.transform.position = tempVec3;
    }
}
Hello There

Camera Suivre l'unité du joueur

using UnityEngine;
using System.Collections;

public class Camera_Follow : MonoBehaviour
{
public GameObject player;
private Vector3 offset;
private Vector3 newtrans;

void Start ()
{
    offset.x = transform.position.x - player.transform.position.x;
    offset.z = transform.position.z - player.transform.position.z;
    newtrans=transform.position;
//not taking y as we wont update y position. 

}

void LateUpdate ()
{
newtrans.x= player.transform.position.x + offset.x;
newtrans.z= player.transform.position.z + offset.z;
transform.position = newtrans;
}
}
Funny Fly

Réponses similaires à “Camera Suivre l'unité du joueur”

Questions similaires à “Camera Suivre l'unité du joueur”

Plus de réponses similaires à “Camera Suivre l'unité du joueur” dans C#

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code