Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class PaddleScript : MonoBehaviour
- {
- //paddle speed
- public float speed = 5f;
- void Update()
- {
- Move();
- }
- //movement function
- void Move()
- {
- //Getting information from left-right arrows or a-d keys to see which way we should move
- //GetAxisRaw returns only -1, 0, or 1 so our speed is constant
- float x = Input.GetAxisRaw("Horizontal");
- //Calculating speed, direction and elapsed time between frames
- float speddDir = x * speed * Time.deltaTime;
- //changing the position of our paddle
- transform.position += new Vector3(speddDir, 0, 0);
- }
- }
Add Comment
Please, Sign In to add comment