0
2
6 лет назад
Отредактирован Uber
0

» Unity / Прыжок

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

public class playerController : MonoBehaviour {

	public float VertImp;
	Rigidbody2D rb;

	if (grounted)
	{
		rb.AddForce(Vector2.up * strenght);
	}

	void Start () {
		rb = GetComponent<Rigidbody2D> ();
	}

	void FixedUpdate () {
		if (Input.tochCount > 0) {
			rb.AddForce (new Vector2 (0, VertImp), ForceMode2D.Impulse);
			foreach(Touch t in Input.touches)
		}
	}
}
мой код стал выглядеть вот так, а ошибки, тут и говорить нечего.
**Assets/script/playerController.cs(10,3): error CS1519: Unexpected symbol `if' in class, struct, or interface member declaration
Assets/script/playerController.cs(10,14): error CS1519: Unexpected symbol `)' in class, struct, or interface member declaration**
error CS9010: Primary constructor body is not allowed
Assets/script/playerController.cs(23,2): error CS1525: Unexpected symbol `}'
0
2
6 лет назад
Отредактирован N7 Molot
0

» Unity / Прыжок

ledoed:
ООО спасибо! Это точно!
ledoed:
Зделал всё по инструкции с интернета + твои советы, исправил все ошибки, но выдало последнюю ошибку The type or namespace name `RigitBody2D' could not be found. Are you missing an assembly reference? Не знаю как исправить! если хочешь вот код:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class playerController : MonoBehaviour {

	public float VertImp;
	RigidBody2D rb;

	void Start () {
		rb = GetComponent<RigitBody2D> ();
	}

	void Update () {
		if (Input.toches ()) {
			RigitBody.AddForce (new Vector2 (0, VertImp), ForceMode2D.impulse);
		}
	}
}
ledoed:
Я кароч немного исправил, но ошибка тут!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class playerController : MonoBehaviour {

	public float VertImp;
	RigidBody2D rb;

	void Start () {
		rb = GetComponent<RigidBody2D> ();
	}

	void FixedUpdate () {
		if (Input.toches ()) {
			rb.AddForce (new Vector2 (0, VertImp), ForceMode2D.impulse);
		}
	}
}