RobloxではLuaというプログラム言語を使います。
僕はプログラム言語なんてクラスさえあればどれも同じと思っているので、Luaはクラスがある同じような言語のひとつです。
Luaはスクリプト言語なのでコンパイルは必要ありません。
たとえば、こんな感じです。
part = script.Parent
while true do
rnd = math.random(6)+1
part.CFrame = part.CFrame + Vector3.new(0,1,0) -- move 1.0 to y direction
part.CFrame = part.CFrame * CFrame.Angles(0, math.rad(rnd), 0) -- rotate randomized degrees around Y axis
wait(0.01)
end
なんのこっちゃ、と思う人が殆どかもしれませんね。<br>
これは0.01秒ごとにものを上に飛ばせてランダムな角度回すスクリプトです。<br>
whileループが更新処理になり、その前が初期化処理になります。<br>
ゲームエンジンによるゲーム開発は大抵こういう処理になっていてUnityのスクリプトも同様で同じことを書くと以下のようになります。
using System.Collections;
using System.Collections.Generic;
using UnityEditor.Timeline;
using UnityEngine;
public class AhoAhoMan : MonoBehaviour
{
float ctime;
float interval = 0.01f;
void Start()
{
ctime = 0f;
}
// Update is called once per frame
void Update()
{
if (ctime > interval)
{
this.transform.Translate(0, 1f, 0);
float r = Random.Range(1f, 6f);
this.transform.Rotate(0, r, 0);
ctime = 0;
}
else
{
ctime += Time.deltaTime;
}
}
}
なんか、若干Unityの方が難しそうに見えますが、Roblox側のpart.FrameがUnity側のthis.tranformに相当すると考えれば…
UnityのStart()がRobloxのwhile文の前、UnityのUpdate()がwhile文内と考えれば…<br>
対応して見えませんでしょうかね?見えないか…
https://www.programates.net/images/scenes/IOHD0019.MP4
ここでスクリプトを付けた板切れがぴょんぴょん跳ねる動画が見られます。
体験申し込みお待ちしております。