Introduction
In the previous posts, I introduced the basic concept of the game and implemented the login screen. From this article onwards, I will introduce the implementation of the main part of the game. We will cover the following topics, each of which is currently under active development.
User Animation and ItemsTimerBasic Rules ( Victory, Defeat )Mirror- Mirror Movement ( Through, Break, Trap )
This post will shows the implementation of Mirror mechanism.
Summary of the implementation of Mirror mechanism
At this time, mirrors can be choke points, offering players strategic options to enhance the game's enjoyment. Players can use mirrors to move to another worlds, destroy mirrors, and set traps. In this implementation, we've added functions for moving and destroying mirrors.
Moving via Mirrors
Players can use mirrors to move to another world. To keep the implementation simple, we've prepared two same levels, and using a mirror changes the player's position accordingly. To indicate the transition to the user, we adjust the lighting to represent the mirror world.
Code Example
[PunRPC]
public void MoveAnotherWorld(float distance)
{
Vector3 currentPosition = transform.position;
// Z direction -83.4
currentPosition.z += distance;
// move
transform.position = currentPosition;
}
Here's the video of moving via mirrors.
Breaking Mirrors
The Survivor has the ability to destroy mirrors, rendering them unusable and preventing Hunters from passing through.
The implementation is relatively easy : when using the gun, it casts a ray to detect collisions. If the hit object is a mirror and it's usable, the destruction process is executed.
Code Example
Ray ray = cam.ViewportPointToRay(new Vector2(0.5f, 0.5f));
if(Physics.Raycast(ray, out RaycastHit hit))
{
if(hit.collider.gameObject.tag == "Mirror")
{
Mirror mirror = hit.collider.gameObject.GetComponent<Mirror>();
if (mirror != null)
{
mirror.Break();
mirror.DisableMirror();
}
}
}
Here's the video of breaking mirrors.
Conclusion
This time, We could not implement the trap function, so I'd like to try it in next time.
User Animation and ItemsTimerBasic Rules ( Victory, Defeat )MirrorMirror Movement ( Through, Break, Trap )
Top comments (0)