Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class PlayerController : MonoBehaviour {
- public Rigidbody rb;
- [SerializeField] private float force;
- [SerializeField] private Transform cameraPos;
- [SerializeField] private Vector3 difference;
- // Use this for initialization
- void Start () {
- rb = GetComponent<Rigidbody>();
- }
- // Update is called once per frame
- void Update ()
- {
- if (Input.GetKey("d"))
- {
- rb.AddForce(force * Time.deltaTime, 0f, 0f, ForceMode.Impulse);
- }
- if(Input.GetKey("a"))
- {
- rb.AddForce(-force * Time.deltaTime, 0f, 0f, ForceMode.Impulse);
- }
- if (Input.GetKey("w"))
- {
- rb.AddForce(0f, 0f, force * Time.deltaTime, ForceMode.Impulse);
- }
- if (Input.GetKey("s"))
- {
- rb.AddForce(0f, 0f, -force * Time.deltaTime, ForceMode.Impulse);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement