void FixedUpdate() { //if (!spawning) // return; spawnTimer -= Time.fixedDeltaTime; if (spawnTimer <= 0) { Tile tile = GetRandomUnusedTile(); if (tile != null) { SupplyCrate crate = Instantiate(scPrefab, tile.transform.position + Vector3.up * yOffset, Quaternion.identity); crate.SetParent(tile); } //else spawning = false; spawnTimer = spawnInterval; } }
public void Explode(Vector3 direction, float force, Player owner = null) { if (owner != null) { lastPlayerHitBy = owner; } if (type == InteractableType.GROUND) { return; } if (type == InteractableType.OBSTACLE) { SupplyCrate crate = GetComponent <SupplyCrate>(); if (crate) { crate.OnExplode(); } } force = Mathf.Max(force - weight, 0f); rb.AddForce(direction * force, ForceMode.VelocityChange); }
/// <summary> /// Checks if the object is a SupplyCrate /// </summary> /// <returns>Returns true if it is.</returns> public bool IsSupplyCrate() { SupplyCrate str = this.Object as SupplyCrate; return(str != null); }