Unity WASD kodu

efegerger

Decapat
Katılım
5 Ağustos 2023
Mesajlar
389
Çözümler
2
Daha fazla  
Cinsiyet
Erkek
Meslek
Bilgisayar Mühendisi
Merhaba Unity'de 3D oyun yapıyorum. Ve bana WASD kodu gerek, internettekilerde hiçbiri çalışmıyor. Eğer çalışan bir kod varsa gönderebilir misiniz? Ama sadece WASD kodu olsun mouse ile hiçbir şey olmasın.
 
Son düzenleyen: Moderatör:
Using unityengine;

Public class playermovement: Monobehaviour.
{
Public float movespeed = 5F;
Private rigidbody2D RB;
Private Vector2 moveınput;

Void Start()
{
RB = GetComponent<Rigidbody2D>();
}

Void Update()
{
// Wasd veya ok tuşlarıyla giriş al.
Moveınput. X = ınput. Getaxisraw("horizontal"); // a (-1) ve D (+1)
Moveınput. Y = ınput. Getaxisraw("vertical"); // W (+1) ve s (-1)

Moveınput = moveınput. Normalized; // diagonal (çapraz) hızını sabitler.
}

Void fixedUpdate()
{
// Karakteri hareket ettir.
RB. Velocity = moveınput * movespeed;
}
}
Hocam karaktere rigibody2 ekleyip kodu karaktere ekleyin.
 
Using unityengine;

Public class playermovement: Monobehaviour.
{
Public float movespeed = 5F;
Private rigidbody2D RB;
Private Vector2 moveınput;

Void Start()
{
RB = GetComponent<Rigidbody2D>();
}

Void Update()
{
// Wasd veya ok tuşlarıyla giriş al.
Moveınput. X = ınput. Getaxisraw("horizontal"); // a (-1) ve D (+1)
Moveınput. Y = ınput. Getaxisraw("vertical"); // W (+1) ve s (-1)

Moveınput = moveınput. Normalized; // diagonal (çapraz) hızını sabitler.
}

Void fixedUpdate()
{
// Karakteri hareket ettir.
RB. Velocity = moveınput * movespeed;
}
}
Hocam karaktere rigibody2 ekleyip kodu karaktere ekleyin.
Hocam Kodu Türkçesiz Ve Tam Haliyke Verebilirmisiniz?
 
Hocam Kodu Türkçesiz Ve Tam Haliyke Verebilirmisiniz?
using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
public float moveSpeed = 5f;
private Rigidbody2D rb;
private Vector2 moveInput;

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

void Update()
{
moveInput.x = Input.GetAxisRaw("Horizontal");
moveInput.y = Input.GetAxisRaw("Vertical");
moveInput = moveInput.normalized;
}

void FixedUpdate()
{
rb.velocity = moveInput * moveSpeed;
}
}
 

Technopat Haberler

Yeni konular

Yeni mesajlar

Geri
Yukarı