Untitled
unknown
csharp
3 years ago
650 B
13
Indexable
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public int movespeed;
public Rigidbody2D rb;
private void Start()
{
rb = gameObject.GetComponent<Rigidbody2D>();
}
private void Update()
{
Move();
}
private void Move()
{
var velocityHor = Input.GetAxis("Horizontal");
var velocityVer = Input.GetAxis("Vertical");
Debug.Log("yatay degerim: " + velocityHor);
Debug.Log("dikey degerim: " + velocityVer);
rb.velocity = new Vector2(velocityHor, velocityVer) * movespeed;
}
}
Editor is loading...