Skip to content

Instantly share code, notes, and snippets.

@NickDiMucci
Last active December 14, 2015 06:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NickDiMucci/5043765 to your computer and use it in GitHub Desktop.
Save NickDiMucci/5043765 to your computer and use it in GitHub Desktop.
Example showing GetComponent usage to access a prefab's script.
public Transform bullet;
private void fireBullet() {
Transform gameObject = Instantiate(bullet, gun.position, gun.rotation) as Transform;
gameObject.GetComponent<EnemyBullet>().setSpeed(speed + BULLET_SPEED_MULTIPLIER);
laser.Play();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment