SAILIPTIK
Знаток
(397)
4 года назад
Using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour
{
float Ver, Hor, Jump;
bool isGround;
public float Speed = 10, JumpSpeed;
void OnCollisionStay(Collision collision)
{
if(collision.gameObject.tag == "ground")
{
isGround = true;
}
}
void OnCollisionExit(Collision collision)
{
if (collision.gameObject.tag == "ground")
{
isGround = false;
}
}
void Update()
{
if (isGround)
{
Ver = Input.GetAxis("Vertical") * Time.deltaTime * Speed;
Hor = Input.GetAxis("Horizontal") * Time.deltaTime * Speed;
Jump = Input.GetAxis("Jump") * Time.deltaTime * JumpSpeed;
GetComponent().AddForce(transform.up * Jump, ForceMode.Impulse);
}
transform.Translate(new Vector3(Hor, 0, Ver));
}
}
Тарас ЛознийУченик (76)
4 года назад
Assets\NewBehaviourScript.cs(2,1): error CS1529: A using clause must precede all other elements defined in the namespace except extern alias declarations
у меня теперь эта ошибка
Using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour
{
float Ver, Hor, Jump;
bool isGround;
public float Speed = 10, JumpSpeed;
void OnCollisionStay(Collision collision)
{
if(collision.gameObject.tag == "ground")
{
isGround = true;
}
}
void OnCollisionExit(Collision collision)
{
if (collision.gameObject.tag == "ground")
{
isGround = false;
}
}
void Update()
{
if (isGround)
{
Ver = Input.GetAxis("Vertical") * Time.deltaTime * Speed;
Hor = Input.GetAxis("Horizontal") * Time.deltaTime * Speed;
Jump = Input.GetAxis("Jump") * Time.deltaTime * JumpSpeed;
GetComponent().AddForce(transform.up * Jump, ForceMode.Impulse);
}
transform.Translate(new Vector3(Hor, 0, Ver));
}
}