Unity
13
Вклад в тег
using UnityEngine;
public class SnotCreater : MonoBehaviour
{
public GameObject Circle;
public GameObject CirclePrefab;
void Start()
{
}
void Update()
{
if (Input.GetMouseButtonDown(0))
{
var mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
Circle = Instantiate(CirclePrefab, mousePos, Quaternion.Euler(0,0,0)) as GameObject;
}
}
}
public class PlayerController : MonoBehaviour
{
Rigidbody2D m_Rigidbody;
readonly Vector2 force = new Vector2(50, 50);
bool inAir;
private void Start()
{
m_Rigidbody = GetComponent<Rigidbody2D>();
}
void Update()
{
if (Input.GetKey(KeyCode.Space) && !inAir)
{
inAir = true;
m_Rigidbody.AddForce(force);
}
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.layer == LayerMask.NameToLayer("Ground"))
inAir = false;
}
}