Skip to content

Instantly share code, notes, and snippets.

@WakkyFree

WakkyFree/ShootBall.cs

Last active Feb 14, 2020
Embed
What would you like to do?
Unity script to shoot a ball
using UnityEngine;
using System.Collections;
public class ShootBall : MonoBehaviour {
private float timer = 0.0f;
private float timeLimit = 1.0f;
public static bool shootSwitch;
// Use this for initialization
void Start () {
shootSwitch = true;
}
// Update is called once per frame
void Update () {
if(shootSwitch) {
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

This comment has been minimized.

Copy link

@UrMummasRoadnan UrMummasRoadnan commented Feb 14, 2020

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