Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using TMPro;
- public class PlayerController : MonoBehaviour
- {
- public float speed = 10.0f;
- Rigidbody rb;
- [SerializeField]
- private Vector3 movement;
- TextMeshProUGUI scoreText;
- int score = 0;
- void Start()
- {
- rb = this.GetComponent<Rigidbody>();
- scoreText = GameObject.Find("ScoreText").GetComponent<TextMeshProUGUI>();
- }
- void Update()
- {
- movement = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
- //transform.Translate(movement * speed * Time.deltaTime);
- }
- private void FixedUpdate()
- {
- //rb.AddForce(movement * speed);
- //rb.velocity = movement * speed;
- rb.MovePosition(transform.position + (movement * speed * Time.deltaTime));
- }
- public void AddScore(int scoreToAdd)
- {
- score += scoreToAdd;
- scoreText.text = "Score: " + score;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement