Skip to content
Snippets Groups Projects
Commit 87b63556 authored by JOLY MICKAEL's avatar JOLY MICKAEL
Browse files

Ajout du script camera centré sur joueur

parent 53ef723e
Branches addCamera
No related merge requests found
......@@ -166,7 +166,7 @@ Rigidbody:
m_GameObject: {fileID: 229716472}
serializedVersion: 2
m_Mass: 1
m_Drag: 4
m_Drag: 10
m_AngularDrag: 999
m_UseGravity: 1
m_IsKinematic: 0
......@@ -264,6 +264,7 @@ GameObject:
- component: {fileID: 405667146}
- component: {fileID: 405667145}
- component: {fileID: 405667144}
- component: {fileID: 405667147}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
......@@ -329,7 +330,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 405667143}
m_LocalRotation: {x: 0.15281336, y: 0, z: 0, w: 0.9882551}
m_LocalRotation: {x: 0.15281336, y: -0, z: -0, w: 0.9882551}
m_LocalPosition: {x: 0, y: 4.21, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
......@@ -337,6 +338,20 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 17.58, y: 0, z: 0}
--- !u!114 &405667147
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 405667143}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2767d535e8d524c68835adc1d9193a97, type: 3}
m_Name:
m_EditorClassIdentifier:
player: {fileID: 229716478}
followSpeed: 2
--- !u!1 &492199260
GameObject:
m_ObjectHideFlags: 0
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraFollow : MonoBehaviour
{
public Transform player;
public float followSpeed = 0.5f;
void Start()
{
}
void Update()
{
Vector3 targetPosition = player.position;
targetPosition.z = player.position.z-10f; // -10f pour éviter de coller la caméra à la capsule.
targetPosition.y += 2f; // Règle la hauteur de la caméra.
transform.position = Vector3.Lerp(transform.position, targetPosition, followSpeed * Time.deltaTime);
}
}
fileFormatVersion: 2
guid: 2767d535e8d524c68835adc1d9193a97
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -6,7 +6,7 @@ public class MouvCharac : MonoBehaviour
{
Rigidbody rigidBody;
public float speed = 1;
public float speed = 1.5f;
Vector3 lookPos;
// Start is called before the first frame update
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment