Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Player : MonoBehaviour {
- public Rigidbody rid;
- public Vector3 direction;
- public float speed = 100f;
- public int points = 0;
- // Use this for initialization
- void Start () {
- rid = GetComponent<Rigidbody>();
- }
- void Update () {
- float h = Input.GetAxis("Horizontal");
- float v = Input.GetAxis("Vertical");
- direction.x = h;
- direction.z = v;
- rid.AddForce(direction.normalized*speed*Time.deltaTime);
- }
- private void OnTriggerEnter(Collider other)
- {
- if (other.CompareTag("cube"))
- {
- points += 1;
- other.gameObject.SetActive(false);
- }
- }
- }
Add Comment
Please, Sign In to add comment