Welcome to GEMENTAR TOUR PUO V2 Development Documentation. Enjoy your stay!

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
wiki:football_explore [2022/08/01 16:30] – created adminwiki:football_explore [2022/08/01 17:29] (current) – [Football Minigame] admin
Line 1: Line 1:
 + --- //[[admin@puov2.gementar.com|Hilmi]] 2022/08/01 17:28//
 +
 +====== Football Minigame ======
 +
 +{{ :wiki:fsmm.gif?nolink |}}
 +
 +<file | Finsihed Minigame > 
 +This is the finished Minigame for football side minigame in Explore Module!
 +</file>
 ====== Prototyping ====== ====== Prototyping ======
 +
  
 {{ :wiki:image_2022-08-02_002932464.png?nolink&600 |}} {{ :wiki:image_2022-08-02_002932464.png?nolink&600 |}}
  
  
 +
 +<file | Prototyping > 
 +This is the prototype scene of football side minigame, The target of this side minigame people can interact and play it without trying to score.
 +This time I'll using auto/modular cone placement.
 +</file>
 +
 +====== State Machine ======
 +
 +{{ :wiki:fsm.gif?nolink |}}
 +
 +<file | Finite State Machine >
 +If ball detected in goal net it will fireup action state, it will play feedback, particle, audio, and reset those cone and ball.
 +
 +</file>
 +====== State Machine ======
 +
 +{{ :wiki:football.gif?nolink |}}
 +
 +<file | Automatic cone placer (Dynamic/Modular) Cone respawn > 
 +So I create a area with a drawable Gizmos, 
 +
 +Gizmos.DrawWireCube(cone.transform.position, new Vector3(rangeX , 3, rangeZ));
 +
 +I draw the gizmos at parent location with random rangeX and rangeZ, so as you can se above the RED line is the range I draw.
 +
 +The blue one shows that I'm using random location at random point ex (0,1) (1,0) from the location.
 +Everytime user scored it will reset and set 6 cone at random location.
 +</file>
 +
 +<code CSharp | Full Script>
 +
 +using Sirenix.OdinInspector;
 +using System.Collections;
 +using System.Collections.Generic;
 +using UnityEngine;
 +using System;
 +
 +
 +public class FootBallMiniGame : MonoBehaviour
 +{
 +
 +    public ParticleSystem particle;
 +    public bool ballDetected = false;
 +
 +    public Transform ballResetPosition;
 +    public Transform ball;
 +
 +    public GameObject conePrefab;
 +    public Transform coneGizmo;
 +    public float rangeX = 5f;
 +    public float rangeZ = 5f;
 +
 +    private void Start() => createCone();
 +
 +    public void playParticle() => particle.Play();
 +
 +    public void footBallDetected() => ballDetected = true;
 +
 +    public void footBallLossDetection()
 +    {
 +        ballDetected = false;
 +    }
 +
 +    private void OnDrawGizmos()
 +    {
 +        Transform cone = coneGizmo.transform;
 +
 +        Gizmos.color = Color.red;
 +        Gizmos.DrawWireCube(cone.transform.position, new Vector3(rangeX, 3, rangeZ));
 +
 +
 +        float x = UnityEngine.Random.Range(cone.transform.position.x, cone.transform.position.x);
 +        float z = UnityEngine.Random.Range(cone.transform.position.z, cone.transform.position.z);
 +
 +        float randX = UnityEngine.Random.Range(-rangeX, rangeX);
 +        float randZ = UnityEngine.Random.Range(-rangeZ, rangeZ);
 +
 +        Gizmos.color = Color.blue;
 +        float xZ = cone.transform.position.x + (int)Math.Round((decimal)randX) / 2;
 +        float zZ = cone.transform.position.z + (int)Math.Round((decimal)randZ) / 2;
 +        Gizmos.DrawWireCube(new Vector3(xZ, cone.transform.position.y, zZ), new Vector3(1, 1, 1));
 +    }
 +
 +    public void resetBall()
 +    {
 +        ball.transform.position = ballResetPosition.position;
 +
 +        //Stop Moving/Translating
 +        ball.GetComponent<Rigidbody>().velocity = Vector3.zero;
 +
 +        //Stop rotating
 +        ball.GetComponent<Rigidbody>().angularVelocity = Vector3.zero;
 +
 +        createCone();
 +    }
 +
 +    public bool getFootBallStatus()
 +    {
 +        return ballDetected;
 +    }
 +
 +    private List<GameObject> newItemList = new List<GameObject>();
 +    [Button]
 +    public void createCone()
 +    {
 +        if (newItemList != null)
 +        {
 +            foreach (var item in newItemList)
 +            {
 +                Destroy(item);
 +            }
 +        }
 +
 +        for (int i = 0; i < 6; i++)
 +        {
 +            Transform cone = coneGizmo.transform;
 +
 +            float randX = UnityEngine.Random.Range(-rangeX, rangeX);
 +            float randZ = UnityEngine.Random.Range(-rangeZ, rangeZ);
 +
 +            float x = cone.transform.position.x + (int)Math.Round((decimal)randX) / 2;
 +            float z = cone.transform.position.z + (int)Math.Round((decimal)randZ) / 2;
 +
 +            var newPos = new Vector3(x, cone.transform.position.y, z);
 +
 +            var newItem = Instantiate(conePrefab, this.gameObject.transform);
 +            newItem.transform.SetParent(cone);
 +            newItem.transform.position = newPos;
 +
 +            newItemList.Add(newItem);
 +        }
 +    }
 +
 +
 +}
 +
 +</code>

QR Code
QR Code wiki:football_explore (generated for current page)
Hello World!
DokuWiki with monobook... rules!