Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using UnityEngine;
- public class Player : MonoBehaviour
- {
- [SerializeField] private float speed;
- [SerializeField] private float horizontalInput;
- [SerializeField] private float verticalInput;
- /*
- private void OnCollisionEnter(Collision other)
- {
- throw new NotImplementedException();
- }
- */
- private void OnTriggerEnter(Collider other)
- {
- if (other.CompareTag("Diamond"))
- {
- speed++;
- print("Diamond Collected");
- Destroy(other.gameObject);
- }
- }
- void Update()
- {
- Controls();
- }
- private void Controls()
- {
- horizontalInput = Input.GetAxis("Horizontal");
- verticalInput = Input.GetAxis("Vertical");
- // new vector3(-1,0,0) * 5 * real time
- transform.Translate(new Vector3(horizontalInput,0,verticalInput) * speed * Time.deltaTime);
- }
- }
- /* Thankyou Baccho */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement