ofb/Assets/Scripts/Launch.cs

18 lines
646 B
C#
Raw Normal View History

2023-04-11 19:55:24 -07:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Launch : MonoBehaviour {
[SerializeField] GameObject tambourine;
[SerializeField] private float horizSpeed;
[SerializeField] private float vertSpeed;
public void ThrowTambourine(float facing) {
2023-04-11 19:55:24 -07:00
GameObject newTambourine = Instantiate(tambourine, this.gameObject.transform.position, this.gameObject.transform.rotation);
// multiply horizSpeed by facing if not using moving launch point
newTambourine.GetComponent<Rigidbody2D>().AddForce(new Vector2(horizSpeed * facing, vertSpeed), ForceMode2D.Impulse);
}
}