Untitled

 avatar
Nullyx
csharp
a year ago
944 B
3
Indexable
Never
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class OurCharacter : Character
{
    private void Update()
    {
        Shoot();
        CharachterMovement();
    }
    void CharachterMovement()
    {
        float forwardMovement = Input.GetAxis("Vertical") * charachterProp.speed * Time.deltaTime;
        float turnMovement = Input.GetAxis("Horizontal") * charachterProp.turnSpeed * Time.deltaTime;

        transform.Translate(Vector3.forward * forwardMovement);
        transform.Rotate(Vector3.up * turnMovement);
    }


    void Shoot()
    {
        if (Input.GetButtonDown("Fire1") && myStuff.bullets > 0)
        {
            Rigidbody bulletInstance = Instantiate(bulletPrefab, firePosition.position, firePosition.rotation) as Rigidbody;
            bulletInstance.AddForce(firePosition.forward * bulletSpeed);
            myStuff.bullets--;
        }
    }
}