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

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

Фид Дип Знаток (285), на голосовании 1 неделю назад
Делаю шутер и написал скрипт на ходьбу но вылетают ошибки, кто шарит помогите

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) ;
}
}
Голосование за лучший ответ
Челл Челов Гуру (2539) 1 месяц назад
Ну хоть не долфин или паскаль..
МаксимИскусственный Интеллект (198416) 1 месяц назад
Да щас Unity самый популярный игровой движок, поэтому ничего удивительного.
ronin Знаток (281) 1 месяц назад
 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);
}
}
Похожие вопросы