【发布时间】:2022-12-18 16:35:52
【问题描述】:
我正在尝试制作对象旋转时向左飞.
这里是向左移动脚本:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MoveLeft : MonoBehaviour
{
private float moveLeftSpeed = 10;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
transform.Translate(Vector3.left * Time.deltaTime * moveLeftSpeed);
}
}
还有自旋对象脚本:
using System.Collections.Generic;
using UnityEngine;
public class SpinObjectsX : MonoBehaviour
{
public float spinSpeed = 50;
// Update is called once per frame
void Update()
{
transform.Rotate(new Vector3(0, Time.deltaTime * spinSpeed, 0));
}
}
我希望物体的运动看起来像这样,它只是向左移动并自旋。
但是当我同时使用这两个脚本时,对象的移动非常奇怪,它仍然在自转但不是向左移动,而是绕着某个东西旋转......
【问题讨论】: