Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- // This is the Swordbeam script.
- public class SwordbeamScript : MonoBehaviour
- {
- // This is my timer.
- [SerializeField] private float memberDuration = 1.0f;
- private float memberTimer = 0.0f;
- // Start a Swordbeam once when it's created.
- [SerializeField] private GameObject memberSwordbeamPrefab = null;
- [SerializeField] private float memberSpeed = 1.0f;
- [SerializeField] private Vector3 memberDirection = Vector3.one;
- // I STILL don't know. Rigid Body.
- private Rigidbody2D memberRigidBody = null;
- protected void Start()
- {
- memberTimer = memberDuration;
- // Get the rigid body that we added in Unity.
- memberRigidBody = this.GetComponent<Rigidbody2D>();
- // Calculate the velocity.
- Vector3 localWhichVelocity;
- localWhichVelocity = memberSpeed * memberDirection;
- }
- // Update a bomb every frame of the game.
- protected void Update()
- {
- memberTimer -= Time.deltaTime;
- if (memberTimer <= 0.0f)
- {
- this.gameObject.SetActive(false);
- }
- Vector3 localPosition;
- localPosition = this.transform.position;
- Instantiate(memberSwordbeamPrefab, localPosition, Quaternion.identity);
- }
- // This completes the Swordbeam.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement