Created
March 11, 2015 08:49
-
-
Save OutlawGameTools/095cf6c1ff30e27d7997 to your computer and use it in GitHub Desktop.
CS109 - A better version of MoveObject that adds randomness and is more generic.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma strict | |
public var xSpeed : int; | |
public var ySpeed : int; | |
public var randomX : boolean = false; | |
public var minXSpeed : int = 100; | |
public var maxXSpeed : int = 200; | |
public var randomY : boolean = false; | |
public var minYSpeed : int = 100; | |
public var maxYSpeed : int = 200; | |
public var resize : boolean = true; | |
public var minSize : float = 0.6f; | |
public var maxSize : float = 1f; | |
function Start () | |
{ | |
if (randomX) | |
xSpeed = Random.Range(minXSpeed, maxXSpeed); | |
if (randomY) | |
ySpeed = Random.Range(minYSpeed, maxYSpeed); | |
var newSpeed : Vector2; | |
newSpeed.x = xSpeed; | |
newSpeed.y = ySpeed; | |
GetComponent.<Rigidbody2D>().AddForce(newSpeed); | |
if (resize) | |
{ | |
var newSize = Random.Range(minSize, maxSize); | |
gameObject.transform.localScale.x = newSize; | |
gameObject.transform.localScale.y = newSize; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment