Q1. 물체를 위로 날려 버리기
void Start()
{
this.GetComponent<Rigidbody2D>().AddForce(new Vector2(0, 800f));
}
Q2. 물체가 점점 커지게 하기
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour
{
float scaleFactor = 1.005f;
float scaleSpeed = 0.01f;
float maxScale = 8.0f;
// Start is called before the first frame update
void Start()
{
//Q1: this.GetComponent<Rigidbody2D>().AddForce(new Vector2(0, 800f));
StartCoroutine(OverTime());
}
System.Collections.IEnumerator OverTime()
{
while (transform.localScale.x < maxScale && transform.localScale.y < maxScale)
{
transform.localScale *= scaleFactor;
yield return new WaitForSeconds(scaleSpeed);
}
}
Q1. 물체를 위로 날려 버리기
void Start()
{
this.GetComponent<Rigidbody2D>().AddForce(new Vector2(0, 800f));
}
Q2. 물체가 점점 커지게 하기
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour
{
float scaleFactor = 1.005f;
float scaleSpeed = 0.01f;
float maxScale = 8.0f;
// Start is called before the first frame update
void Start()
{
//Q1: this.GetComponent<Rigidbody2D>().AddForce(new Vector2(0, 800f));
StartCoroutine(OverTime());
}
System.Collections.IEnumerator OverTime()
{
while (transform.localScale.x < maxScale && transform.localScale.y < maxScale)
{
transform.localScale *= scaleFactor;
yield return new WaitForSeconds(scaleSpeed);
}
}