Unity karakter asılı kalıyor

TeknoGame20

Hectopat
Katılım
18 Ocak 2021
Mesajlar
268
Makaleler
1
Daha fazla  
Cinsiyet
Erkek
Merhaba. Ben Unity 2D öğreniyorum. Kodları doğru yapmama rağmen karakter 0.0.0 pozisyonunda asılı kalıyor.

C#:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
 Rigidbody2D rgb;
 Vector3 velocity;
 float speedAmount = 5f;

 void Start()
 {
 rgb = GetComponent<Rigidbody2D>();
 }

 void Update()
 {
 velocity = new Vector3(Input.GetAxis("Horizontal"), 0f);
 transform.position += velocity * speedAmount * Time.deltaTime;
 }
}
 
Son düzenleme:
Merhaba. Ben Unity 2D öğreniyorum. Kodları doğru yapmama rağmen karakter 0.0.0 pozisyonunda asılı kalıyor.

C#:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
 Rigidbody2D rgb;
 Vector3 velocity;
 float speedAmount = 5f;

 void Start()
 {
 rgb = GetComponent<Rigidbody2D>();
 }

 void Update()
 {
 velocity = new Vector3(Input.GetAxis("Horizontal"), 0f);
 transform.position += velocity * speedAmount * Time.deltaTime;
 }
}
velocity = new Vector3(Input.GetAxis("Horizontal"), -9f);
bu şekilde düzenlersen karakterin aşağı düşecektir ama hiç bir engele takılmayacaktır.
 

Yeni konular

Geri
Yukarı