Skip to content

Instantly share code, notes, and snippets.

@WakkyFree
Last active February 14, 2020 21:14
Show Gist options
  • Save WakkyFree/7e4fcf8d195d8e5c6c48ec748dc8b34d to your computer and use it in GitHub Desktop.
Save WakkyFree/7e4fcf8d195d8e5c6c48ec748dc8b34d to your computer and use it in GitHub Desktop.
Unity script to shoot a ball
using UnityEngine;
using System.Collections;
public class ShootBall : MonoBehaviour {
float timer = 0.0f;
float timeLimit = 1.0f;
bool shootSwitch;
// Use this for initialization
void Start () {
shootSwitch = true;
}
// Update is called once per frame
void Update () {
timer += Time.deltaTime;
if((timer > timeLimit) & shootSwitch) {
float z = 2000; // force strength;
Rigidbody rigidbody = GetComponent<Rigidbody>();
rigidbody.AddForce(0, 0, -z);
timer = 0.0f;
shootSwitch = false;
}
}
}
@UrMummasRoadnan
Copy link

its asking for shoot switch but I cant find that on his acc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment