Skip to content

Free fire #2

@monish77moni-droid

Description

@monish77moni-droid

// PlayerMovement.cs
using UnityEngine;

[RequireComponent(typeof(CharacterController))]
public class PlayerMovement : MonoBehaviour
{
public float speed = 5f;
public float gravity = -9.81f;
public float jumpHeight = 1.2f;
public Transform cam;

CharacterController controller;
Vector3 velocity;

void Start()
{
    controller = GetComponent<CharacterController>();
}

void Update()
{
    float h = Input.GetAxis("Horizontal");
    float v = Input.GetAxis("Vertical");

    Vector3 move = cam.right * h + cam.forward * v;
    move.y = 0;
    controller.Move(move * speed * Time.deltaTime);

    velocity.y += gravity * Time.deltaTime;
    controller.Move(velocity * Time.deltaTime);
}

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions