【发布时间】:2021-01-26 11:41:36
【问题描述】:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Movement : MonoBehaviour
{
public float movementSpeed;
public Rigidbody2D Rigidbody;
private Vector2 moveDirection;
public Transform Player;
void Start()
{
}
void Update()
{
ProcessInputs();
} void FixedUpdate()
{
move();
}
void ProcessInputs()
{
float moveX = Input.GetAxisRaw("Horizontal");
float moveY = Input.GetAxisRaw("Vertical");
moveDirection = new Vector2(moveX, moveY).normalized;
}
void move()
{
Rigidbody.velocity = new Vector2(moveDirection.x * movementSpeed, moveDirection.y * movementSpeed);
}
}
所以我需要一些提示,所以我想在这里问一下,我想在我的 Top-Down-Shooter 中实现冲刺,但我在 Youtube 上没有找到任何可以正确使用我的代码的代码我也尝试过移动玩家位置+2 到想要的方向,但我无法解决。 如果你们能帮助我,我会很高兴。
【问题讨论】:
标签: c# unity3d game-development rigid-bodies