55
edits
Phanchris5 (talk | contribs) No edit summary |
Phanchris5 (talk | contribs) mNo edit summary |
||
Line 57: | Line 57: | ||
|} | |} | ||
But I still | But I still wanted to choose something that is connected to the Silent Hill universe rather than a typical human body part. I made the decision to employ the spooky wicked nurse creature that is lying down in the Silent Hill game and used Blender to break her model into separated limbs. Here was the initial effort: | ||
[[File:fogworld13.png|800px]] | [[File:fogworld13.png|800px]] | ||
Then I painted some trees and grass to make it looks like a swamp | Then I painted some trees and grass to make it looks like a swamp | ||
[[File:fogworld14.png|800px]] | [[File:fogworld14.png|800px]] | ||
[[File:fogworld15.png|800px]] | |||
Here is the final result for the second scene with some volume fog by using URP. | Here is the final result for the second scene with some volume fog by using URP. | ||
[[File:fogworld16.png|400px]] | |||
''' The chasing creature ''' | |||
The chasing creature | |||
In order to give the beast in this scenario some interaction, I made it chase the main character whenever he enters the swamp. | In order to give the beast in this scenario some interaction, I made it chase the main character whenever he enters the swamp. | ||
[[File:fogworld17.png|800px]] | |||
[[File: | The monster is large and empty of materials when I imported it into Unity, so I had to manually extract and remap the material. | ||
[[File:fogworld18.png|800px]] | |||
The monster | |||
[[File: | |||
I then used the Box Collider component in an empty Game Object to build a collider area that would trigger the creature to start chasing it. | I then used the Box Collider component in an empty Game Object to build a collider area that would trigger the creature to start chasing it. | ||
[[File:fogworld19.png|800px]] | |||
Of course, we also need to write a script for the creature to follow the character. | |||
// Reference to the monster game object | |||
public GameObject monster; | |||
// Reference to the character game object | |||
public GameObject target; | |||
// Speed of the monster | |||
public float speed = 5f; | |||
// Rotation speed of the monster | |||
public float rotationSpeed = 0.1f; | |||
private void Start() | |||
{ | |||
UpdateRigidbodyConstraints(); | |||
} | |||
private void UpdateRigidbodyConstraints() | |||
{ | |||
Rigidbody rb = monster.GetComponent<Rigidbody>(); | |||
rb.constraints = RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ; | |||
rb.constraints = RigidbodyConstraints.FreezeAll; | |||
} | |||
private void OnTriggerEnter(Collider other) | |||
{ | |||
// Check if the collider that entered the trigger is the character | |||
if (other.gameObject == target) | |||
{ | |||
// Start chasing the character | |||
StartCoroutine(ChaseTarget()); | |||
} | |||
} | |||
private void OnTriggerExit(Collider other) | |||
{ | |||
// Check if the collider that exited the trigger is the character | |||
if (other.gameObject == target) | |||
{ | |||
// Stop chasing the character | |||
StopAllCoroutines(); | |||
} | |||
} | |||
private IEnumerator ChaseTarget() | |||
{ | |||
// Continuously chase the target while the monster is within the trigger | |||
while (monster.activeInHierarchy) | |||
{ | |||
// Rotate the monster to face the target | |||
Quaternion targetRotation = Quaternion.LookRotation(target.transform.position - monster.transform.position); | |||
monster.transform.rotation = Quaternion.Slerp(monster.transform.rotation, targetRotation, rotationSpeed); | |||
// Move the monster towards the target | |||
monster.transform.position = Vector3.MoveTowards(monster.transform.position, target.transform.position, speed * Time.deltaTime); | |||
yield return null; | |||
} | |||
} | |||
[[File:vertopal_0685f745dbfb4caab4daadf6109cc616/media/image21.png|620x226px]] | [[File:vertopal_0685f745dbfb4caab4daadf6109cc616/media/image21.png|620x226px]] |
edits