игровой объект:
игрок:
Код: Выделить всё
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Move : MonoBehaviour {
public float Speed;
void timeout()
{
Speed = 20f;
}
void Update () {
float verticalInput = Input.GetAxis("Vertical");
Vector3 move = transform.right * verticalInput;
transform.Translate(move * Speed * Time.deltaTime);
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.CompareTag("item"))
{
Speed = 40f;
Destroy(flash);
Invoke("timeout", 5);
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/783 ... ementation