Blindnightmare
Öğrenci
- Katılım
- 23 Ocak 2019
- Mesajlar
- 6
- Reaksiyon puanı
- 1
- Puanları
- 3
- Yaş
- 30
Kod:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class playercontroller : MonoBehaviour
{
public float m_Speed = 6.5f;
public float m_JumpForce = 600f;
public float m_GroundCheckRadius = 0.5f;
public LayerMask m_WhatIsGround;
private Rigidbody2D m.Rigidbody2D;
private Transform m.GroundCheck;
private bool m_Grounded = false;
void Start ()
{
m_Rigidbody2D = GetComponent<Rigidbody2D>;
m_GroundCheck = Transform.Find("GroundCheck");
}
void Update ()
{
float axis_h = Input.GetAxis("Horizontal"); // yatay yön tuşları veya A - D
float axis_v = Input.GetAxis("Vertical"); // dikey yön tuşları veya W - S
m_Grounded = Physics2D.OverlapCircle(m_GroundCheck.position, m_GroundCheckRadius, m_WhatIsGround)
if (axis_h != 0)
{
Vector3 pos = Transform.position;
pos.x += axis_h * m_Speed * Time.deltaTime;
transform.position = pos;
}
if (axis_v == 1 && m_Grounded)
{
m_Rigidbody2D.AddForce(transform.up * m_JumpForce);
}
}
}
Mesaj otomatik birleştirildi:
Yardım edebilir misiniz? Bunun sebebi nedir her şey doğru gibi geliyor bana.