Skip to content

Instantly share code, notes, and snippets.

Created May 29, 2018 12:17
What would you like to do?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GasMolecularMover : MonoBehaviour {
public float minSpeed = 20f;
public float maxSpeed = 30f;
Vector3 force =;
Rigidbody rb;
bool isShoot;
void Start(){
force.x = GetRandomSpeed();
force.y = GetRandomSpeed();
force.z = GetRandomSpeed();
rb = gameObject.GetComponent<Rigidbody>();
void FixedUpdate(){
if (!isShoot){
rb.AddForce(force, ForceMode.VelocityChange);
isShoot = true;
float GetRandomSpeed(){
float speed = 0f;
speed = Random.Range(minSpeed, maxSpeed);
return speed;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment