Search Unity

Games Please Fix My Basketball Game

Discussion in 'Works In Progress - Archive' started by perfectnumber, Apr 4, 2019.

  1. perfectnumber

    perfectnumber

    Joined:
    Dec 24, 2018
    Posts:
    3
    Hi there I am trying to make a first person basketball game. I can't throw my ball and can't start a new round and I am not sure if my problem is in the scripts or the unity editor.

    Player.cs

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityStandardAssets.Vehicles.Ball;

    public class Player : MonoBehaviour {


    public Ball ball;
    public GameObject playerCamera;

    public float ballDistance = 2f;
    public float ballThrowingForce = 5f;

    public bool holdingBall = true;

    // Use this for initialization
    void Start () {
    ball.GetComponent<Rigidbody> ().useGravity = false;
    }

    // Update is called once per frame
    void Update () {
    if (holdingBall) {
    ball.transform.position = playerCamera.transform.position + playerCamera.transform.forward * ballDistance;
    if (Input.GetMouseButtonDown(0)) {
    ball.ActivateTrail();
    holdingBall = false;
    ball.GetComponent<Rigidbody>().useGravity = true;
    ball.GetComponent<Rigidbody>().AddForce(playerCamera.transform.forward * ballThrowingForce);
    }
    }
    }
    }
     
  2. Deleted User

    Deleted User

    Guest

    uh..fix it yourself..

    it does require, you know.. research, code, testing....what everyone starts with..a blank canvas.

    begin with this..

    State Machine Basics
    The basic idea is that a character is engaged in some particular kind of action at any given time. The actions available will depend on the type of gameplay but typical actions include things like idling, walking, running, jumping, etc. These actions are referred to as states
     
    Last edited by a moderator: Apr 4, 2019
    RavenOfCode and sylon like this.