using System.Collections; using System.Collections.Generic; using UnityEngine; public class TennisArea : MonoBehaviour { public GameObject ball; public GameObject agentA; public GameObject agentB; // Use this for initialization void Start () { } // Update is called once per frame void Update () { } public void MatchReset() { float ballOut = Random.Range(4f, 11f); int flip = Random.Range(0, 2); if (flip == 0) { ball.transform.position = new Vector3(-ballOut, 5f, 0f) + transform.position; } else { ball.transform.position = new Vector3(ballOut, 5f, 0f) + transform.position; } ball.GetComponent().velocity = new Vector3(0f, 0f, 0f); ball.transform.localScale = new Vector3(1, 1, 1); } void FixedUpdate() { Vector3 rgV = ball.GetComponent().velocity; ball.GetComponent().velocity = new Vector3(Mathf.Clamp(rgV.x, -9f, 9f), Mathf.Clamp(rgV.y, -9f, 9f), rgV.z); } }