#C8 Site Development and Spike Mechanics

#C8 Site Development and Spike Mechanics

·

2 min read


Introduction:

This update focuses on the design and implementation of game sites, along with the introduction of spike objects and associated mechanics. Game sites serve as crucial locations for planting and defusing spikes, adding strategic depth to gameplay. Spike mechanics include pickup, planting, and defusing functionalities, synchronized in real-time across players.


SpikeScript:

The SpikeScript manages spike pickup mechanics:

  • isPicked: Tracks whether the spike has been picked up by a player.

  • playerController: Reference to the player controller script of the player who picks up the spike.

  • OnTriggerEnter(Collider other): Detects when a player enters the trigger zone of the spike and picks it up if the player is in attack mode and alive.

    ```csharp using Photon.Pun; using UnityEngine;

    public class SpikeScript : MonoBehaviourPun { public bool isPicked = false; public PlayerController playerController;

private void OnTriggerEnter(Collider other) { if (!isPicked && other.CompareTag("Player")) { PhotonView photonView = other.GetComponent(); if ((string)photonView.Owner.CustomProperties["PlayMode"] == "Attack") { if (photonView.GetComponent().isDead == false) { isPicked = true; playerController = other.GetComponent(); playerController.hasSpike = true; playerController.PickUpSpike(this.gameObject); }

}
} }

} ```


Photon Integration:

  • Utilizes Photon networking to synchronize spike interactions across all players in real-time.

Ensures that spike pickup, planting, and defusing functionalities are consistent across the networked game instances.


Conclusion:

With the addition of game sites and spike mechanics, players can engage in strategic gameplay elements such as securing spike locations, planting spikes for offense, and defending against spike threats. The real-time synchronization ensures a seamless multiplayer experience, enhancing immersion and competitiveness. In the next update, we'll explore further refinements and optimizations to improve gameplay dynamics and overall player experience.