【发布时间】:2018-12-05 21:26:34
【问题描述】:
好的,我有一堆立方体,我只需要在太空中缓慢振动/摇晃就好像几乎悬停一样。我首先尝试使用带有噪声的粒子发射器,但无法获得运动部分。我现在正在尝试将脚本附加到每个对象:
float speed = 1.0f; //how fast it shakes
float amount = 1.0f;
public Vector2 startingPos;
void Awake()
{
startingPos.x = transform.position.x;
startingPos.y = transform.position.y;
}
// Update is called once per frame
void Update()
{
float newx = startingPos.x + (Mathf.Sin(Time.time * speed) * amount);
float newy = startingPos.y + (Mathf.Sin(Time.time * speed) * amount);
transform.position = new Vector3(newx, newy, transform.position.z);
}
这样,立方体就完全消失了。我在论坛上查看无济于事 - 我该怎么做才能让立方体振动/悬停在原地?
【问题讨论】:
标签: c# unity3d game-physics game-development