輸送装置の作成
輸送装置
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Transport : MonoBehaviour
{
private int num = 1;
void Update()
{
var pos = transform.position;
transform.Translate(new Vector2(0, num) * Time.deltaTime * 1.2f);
if (pos.y > 3.5f)
{
num = -1;
}
else if (pos.y < -0.5f)
{
num = 1;
}
}
}
【2022版】ActionGame2D(全33回)
他のコースを見る輸送装置
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Transport : MonoBehaviour
{
private int num = 1;
void Update()
{
var pos = transform.position;
transform.Translate(new Vector2(0, num) * Time.deltaTime * 1.2f);
if (pos.y > 3.5f)
{
num = -1;
}
else if (pos.y < -0.5f)
{
num = 1;
}
}
}
輸送装置の作成