в чём ошибка
using UnityEngine;
public class knife : MonoBehaviour
{
[SerializeField]
public Vector2 throwForse;
public bool isActive = true;
public Rigidbody2D rb;
private BoxColider2D knifeColider;
public void Awake()
{
rb = GetComponent();
knife GetComponent();
}
public void Update()
{
rb.addForse(throwForse, ForseMode2D.impulse);
rb.gravityScale = 1;
}
public void OnCollisionEnter(Collision2D collision)
{
if (!isActive)
return;
isActive = false;
if(collision.collider.tag == "player")
{
rb.velosity = new Vector2(0, 0);
rb.bodyType = RigidbodyType2D.Kinematic;
this.Transform.SetParrent(collision.collider.transform);
knifeColider.offset = new Vector2(knifeColider.offset.x, -0.4f);
knifeColider.size = new Vector2(knifeColider.size.x, 1.2f);
}
else if(collision.collider.tag == "player")
{
rb.velosity = new Vector2(rb.velosity.x, -2);
}
}
}
-
Вопрос задан
-
175 просмотров