Помогите решить (99,14): error CS1061 ошибка находится в void flip()
(99,14): error CS1061'Transform' does not contain a definition for 'eulerAngels' and no accessible extension method 'eulerAngels' accepting a first argument of type 'Transform' could be found (are you missing a using directive or an assembly reference?)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerContorller : MonoBehaviour
{
public enum ProjectAxis { onlyX = 0, xAndY = 1 };
public ProjectAxis projectAxis = ProjectAxis.onlyX;
public float speed = 150;
public float drag = 100;
public float addForce = 7;
public bool lookAtCursor;
public KeyCode leftButton = KeyCode.A;
public KeyCode rightButton = KeyCode.D;
public KeyCode upButton = KeyCode.W;
public KeyCode downButton = KeyCode.S;
public KeyCode addForceButton = KeyCode.Space;
public bool isFacingRight = true;
private Vector3 direction;
private float moveInput;
private float vertical;
private float horizontal;
private Rigidbody2D body;
private float rotationY;
private bool jump;
void Start()
{
body = GetComponent<Rigidbody2D>();
body.fixedAngle = true;
if (projectAxis == ProjectAxis.xAndY)
{
body.gravityScale = 0;
body.drag = drag;
}
}
void OnCollisionStay2D(Collision2D coll)
{
if (coll.transform.tag == "Ground")
{
body.drag = drag;
jump = true;
}
}
void OnCollisionExit2D(Collision2D coll)
{
if (coll.transform.tag == "Ground")
{
body.drag = 0;
jump = false;
}
}
void FixedUpdate()
{
body.AddForce(direction * body.mass * speed);
if (Mathf.Abs(body.velocity.x) > speed / 100f)
{
body.velocity = new Vector2(Mathf.Sign(body.velocity.x) * speed / 100f, body.velocity.y);
}
if (projectAxis == ProjectAxis.xAndY)
{
if (Mathf.Abs(body.velocity.y) > speed / 100f)
{
body.velocity = new Vector2(body.velocity.x, Mathf.Sign(body.velocity.y) * speed / 100f);
}
}
else
{
if (Input.GetKey(addForceButton) && jump)
{
body.velocity = new Vector2(0, addForce);
}
}
}
void Flip()
{
if (projectAxis == ProjectAxis.xAndY)
{
isFacingRight = !isFacingRight;
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
if (moveInput < 0)
{
transform.eulerAngels = new Vector3(0, 180, 0);
}
else if (moveInput > 0)
{
transform.eulerAngels = new Vector3(0, 0, 0);
}
}
}
void Update()
{
if (lookAtCursor)
{
Vector3 lookPos = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, Camera.main.transform.position.z));
lookPos = lookPos - transform.position;
float angle = Mathf.Atan2(lookPos.y, lookPos.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
}
if (Input.GetKey(upButton)) vertical = 1;
else if (Input.GetKey(downButton)) vertical = -1; else vertical = 0;
if (Input.GetKey(leftButton)) horizontal = -1;
else if (Input.GetKey(rightButton)) horizontal = 1; else horizontal = 0;
if (projectAxis == ProjectAxis.onlyX)
{
direction = new Vector2(horizontal, 0);
}
else
{
if (Input.GetKeyDown(addForceButton)) speed += addForce; else if (Input.GetKeyUp(addForceButton)) speed -= addForce;
direction = new Vector2(horizontal, vertical);
}
if (horizontal > 0 && !isFacingRight) Flip(); else if (horizontal < 0 && isFacingRight) Flip();
}
}
Ответы (1 шт):
Автор решения: Максим Фисман
→ Ссылка
Angel[ˈeɪnʤəl] - ангелAngle[æŋgl] - угол
Функция для поворота объекта называется eulerAngles - угол Эйлера, Эйлеровский угол
Именно так должна быть написана эта функция в методе Flip()