Mail.ruПочтаМой МирОдноклассникиВКонтактеИгрыЗнакомстваНовостиКалендарьОблакоЗаметкиВсе проекты

Помогите починить код C#

Фид Дип Профи (949), на голосовании 10 месяцев назад
Делаю шутер и написал скрипт на ходьбу но вылетают ошибки, кто шарит помогите

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FPSMovement : MonoBehaviour
{

public float _speed = 6.0f;
private CharacterController _characterController;


private void Start()
{


_characterController = GetComponent<CharacterController>();

if (_characterController == null)
Debug.Log("CharacterController is NULL”);
}

private void Update()
{
float deltax = Input GetAxis("Horizontal”) * _speed;
float deltaz = Input.Getaxis("Vertical”) * _speed;
Vector3 movement = new Vector3(deltax, 0, deltaZ)
movement = Vector3 .Clamphagnitude (movement,
‘novenent.y = gravity;

movenent ‘= Tine.deltatine;
‘movement = transform. Transforabirect ion(ovement));
__characterController.Move(movenent) ;
}
}
Голосование за лучший ответ
Исип Гуру (2686) 11 месяцев назад
Ну хоть не долфин или паскаль..
МаксимИскусственный Интеллект (217589) 11 месяцев назад
Да щас Unity самый популярный игровой движок, поэтому ничего удивительного.
ronin Знаток (350) 11 месяцев назад
 using System.Collections; 
using System.Collections.Generic;
using UnityEngine;

public class FPSMovement : MonoBehaviour
{
public float _speed = 6.0f;
public float gravity = -9.81f;
private CharacterController _characterController;

private void Start()
{
_characterController = GetComponent();

if (_characterController == null)
Debug.Log("CharacterController is NULL");
}

private void Update()
{
float deltax = Input.GetAxis("Horizontal") * _speed;
float deltaz = Input.GetAxis("Vertical") * _speed;
Vector3 movement = new Vector3(deltax, 0, deltaz);

movement = Vector3.ClampMagnitude(movement, _speed);

movement.y = gravity;

movement *= Time.deltaTime;

movement = transform.TransformDirection(movement);

_characterController.Move(movement);
}
}
Похожие вопросы