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 PlayerMovement : MonoBehaviour
- {
- private Rigidbody2D rgdbdy2d;
- public float speed;
- private void Start()
- {
- rgdbdy2d = GetComponent<Rigidbody2D> ();
- }
- private void Update()
- {
- }
- private void FixedUpdate()
- {
- // float moveHor = Input.GetAxis("Horizontal");
- // float moveVer = Input.GetAxis("Vertical");
- // Vector2 mvmnt = new Vector2(moveHor, moveVer);
- // rgdbdy2d.AddForce(mvmnt * speed);
- float moveHor = Input.GetAxisRaw("Horizontal")*speed;
- float moveVer = Input.GetAxisRaw("Vertical") * speed;
- Vector2 mvnmt = new Vector2(moveHor, moveVer);
- rgdbdy2d.velocity = mvnmt;
- rgdbdy2d.freezeRotation = true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement