大佬教程收集整理的这篇文章主要介绍了如何让玩家可以扫射?(Unity 3D),大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我如何扫射?这是 playerMovment 脚本。这是一个fps游戏。相机是玩家的孩子,玩家是一个胶囊。一切正常,但我不确定如何实施扫射。我想要它@R_711_9447@按 WASD 但到目前为止只有 W 和 S 可以工作。这是我的代码:
using System.Collections;
[requireComponent(typeof(CharacterController))]
public class PlayerMovement : MonoBehavIoUr
{
Vector2 rotation = new Vector2(0,0);
public float CamSpeed = 3;
public float speed = 6.0F;
public float jumpSpeed = 8.0F;
public float gravity = 20.0F;
private Vector3 moveDirection = Vector3.zero;
CharacterController controller;
voID Start()
{
controller = GetComponent<CharacterController>();
cursor.lockState = cursorLockmode.Locked;
}
voID update()
{
cAMMove();
if (controller.isGrounded)
{
moveDirection = new Vector3(0,input.GetAxis("Vertical"));
moveDirection = transform.transformDirection(moveDirection);
moveDirection *= speed;
if (input.Getbutton("Jump"))
moveDirection.y = jumpSpeed;
}
moveDirection.y -= gravity * Time.deltaTime;
controller.Move(moveDirection * Time.deltaTimE);
}
public voID cAMMove()
{
rotation.y += input.GetAxis("Mouse X");
rotation.x += -input.GetAxis("Mouse Y");
transform.eulerAngles = rotation * speed;
}
}```
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的如何让玩家可以扫射?(Unity 3D)全部内容,希望文章能够帮你解决如何让玩家可以扫射?(Unity 3D)所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。