Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

TAG

using UnityEngine;

public class TagPlayer : MonoBehaviour

{

    public float speed = 5f;

    void Update()

    {

        float horizontal = Input.GetAxis("Horizontal");

        float vertical = Input.GetAxis("Vertical");

        Vector3 movement = new Vector3(horizontal, 0f, vertical) * speed * Time.deltaTime;

        transform.Translate(movement);

    }

    void OnTriggerEnter(Collider other)

    {

        if (other.CompareTag("Player"))

        {

            Debug.Log("Tagged!");

            

using UnityEngine;

public class OnlineTagGame : MonoBehaviour

{

    public float speed = 5f;

    private bool isTagged = false;

    void Update()

    {

        if (!isTagged)

        {

            // Player movement

            float horizontal = Input.GetAxis("Horizontal");

            float vertical = Input.GetAxis("Vertical");

            Vector3 movement = new Vector3(horizontal, 0f, vertical) * speed * Time.deltaTime;

            transform.Translate(movement);

        }

    }

    void OnTriggerEnter(Collider other)

    {

        if (!isTagged && other.CompareTag("Player"))

        {

            // Tagging logic

            Debug.Log("Tagged!");

            isTagged = true;

            // Add your own effects, scoring, or tagging logic here

        }

    }

}

Support this post

Did you like this post? Tell us

Leave a comment

Log in with your itch.io account to leave a comment.