mirror of
https://github.com/ConjureETS/EscapeTheRoom.git
synced 2026-03-24 01:00:58 +00:00
Le monstre va suivre le player
This commit is contained in:
parent
3724a915c0
commit
04247b313c
8
Assets/Scenes/BenScene.unity.meta
Normal file
8
Assets/Scenes/BenScene.unity.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2c1843c7ef59c4177a8d1c75cf7f8399
|
||||||
|
timeCreated: 1446925711
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
12
Assets/Scripts/FirstPersonController.cs.meta
Normal file
12
Assets/Scripts/FirstPersonController.cs.meta
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4bcce75dab8f540b797340354c772d8b
|
||||||
|
timeCreated: 1446927249
|
||||||
|
licenseType: Free
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -9,6 +9,9 @@ public class monsterAI : MonoBehaviour
|
|||||||
public float rotationDamping; // Lower rotation damping = slower rotation
|
public float rotationDamping; // Lower rotation damping = slower rotation
|
||||||
public float moveSpeed;
|
public float moveSpeed;
|
||||||
|
|
||||||
|
|
||||||
|
public float distance;
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void Start ()
|
void Start ()
|
||||||
{
|
{
|
||||||
@ -31,15 +34,16 @@ public class monsterAI : MonoBehaviour
|
|||||||
// Check is the current distance is deadly for the target
|
// Check is the current distance is deadly for the target
|
||||||
bool IsAtDeadlyDistance ()
|
bool IsAtDeadlyDistance ()
|
||||||
{
|
{
|
||||||
return (deadlyDistance <= Vector3.Distance (target.position, transform.position));
|
return (Vector3.Distance (target.position, transform.position) <= deadlyDistance);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look toward target
|
// Look toward target
|
||||||
void LookAtTarget ()
|
void LookAtTarget ()
|
||||||
{
|
{
|
||||||
//Quaternion rotation = Quaternion.LookRotation (target.rotation - transform.rotation);
|
Vector3 relativePos = target.position - transform.position;
|
||||||
//transform.rotation = Quaternion.Slerp (transform.rotation, rotation, Time.deltaTime * rotationDamping);
|
Quaternion rotation = Quaternion.LookRotation (relativePos);
|
||||||
|
|
||||||
|
transform.rotation = Quaternion.Slerp (transform.rotation, rotation, Time.deltaTime * rotationDamping);
|
||||||
}
|
}
|
||||||
// Follow player from a certain initial distance at a certain speed.
|
// Follow player from a certain initial distance at a certain speed.
|
||||||
void MoveTowardTarget ()
|
void MoveTowardTarget ()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user