Programming Expertise

With over 5 years of experience in C# and Unity, I specialize in writing clean and performant code. I also have a strong background in Python, Java, and Web Technologies. Below is some scripts I have written for diffrent games.

CharacterController.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player : MonoBehaviour
{
    [SerializeField] float speed = 5f;
    [SerializeField] LayerMask aimMask;

    public static Vector3 direction;
    public static Animator animator;
    public static Player player;

    Rigidbody rb;
    Vector3 move;

    float x;
    float z;

    float moveX;
    float moveZ;

    void Awake()
    {
        player = this;
        animator = GetComponent<Animator>();
        rb = GetComponent<Rigidbody>();
    }

    void Start()
    {
        gameObject.name = "Player";
    }

    void Update()
    {
        ReadInput();
        AimTowardMouse();
        UpdateAnimator();
        UpdateKinematic();
    }

    void FixedUpdate()
    {
        MovePlayer(move);
    }

    void ReadInput()
    {
        x = Input.GetAxisRaw("Horizontal");
        z = Input.GetAxisRaw("Vertical");

        move = new Vector3(x, 0f, z).normalized;

        moveZ = Vector3.Dot(move, transform.forward);
        moveX = Vector3.Dot(move, transform.right);
    }

    void MovePlayer(Vector3 dir)
    {
        transform.position += dir * speed * Time.deltaTime;
    }

    void AimTowardMouse()
    {
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if (Physics.Raycast(ray, out var hit, Mathf.Infinity, aimMask))
        {
            Vector3 target = hit.point;
            target.y = transform.position.y;

            Vector3 dir = (target - transform.position).normalized;

            transform.forward = dir;
            direction = dir;
        }
    }

    void UpdateAnimator()
    {
        animator.SetFloat("VelocityZ", moveZ, 0.1f, Time.deltaTime);
        animator.SetFloat("VelocityX", moveX, 0.1f, Time.deltaTime);
    }

    void UpdateKinematic()
    {
        rb.isKinematic = Mathf.Approximately(x, 0f) && Mathf.Approximately(z, 0f);
    }
}
                        

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;

public class Enemy : MonoBehaviour
{
    [SerializeField] NavMeshAgent nav;
    [SerializeField] Transform target;
    [SerializeField] LayerMask playerMask;
    [SerializeField] LayerMask blockMask;
    [SerializeField] Collider hitbox;
    [SerializeField] Animator anim;
    [SerializeField] Transform firePoint;
    [SerializeField] GameObject hellWeapon;
    [SerializeField] GameObject projectilePrefab;
    [SerializeField] ParticleSystem flash;
    public float viewRadius;
    [Range(0,360)] public float viewAngle;
    public float shootDistance;
    [SerializeField] float attackCooldown = 1f;
    public bool seesPlayer;
    public bool dead;
    Vector3 smoothVelocity;
    Coroutine visionRoutine;

    void Awake()
    {
        dead = false;
        nav.updateRotation = false;
        gameObject.name = "Enemy";
        visionRoutine = StartCoroutine(VisionLoop());
    }

    IEnumerator VisionLoop()
    {
        WaitForSeconds delay = new WaitForSeconds(0.2f);
        while (true)
        {
            yield return delay;
            CheckVision();
            if (seesPlayer && Vector3.Distance(transform.position, target.position) <= shootDistance)
            {
                Shoot();
            }
        }
    }

    void CheckVision()
    {
        Collider[] hits = Physics.OverlapSphere(transform.position, viewRadius, playerMask);

        if (hits.Length > 0)
        {
            Transform t = hits[0].transform;
            Vector3 dir = (t.position - transform.position).normalized;
            if (Vector3.Angle(transform.forward, dir) < viewAngle / 2)
            {
                float dist = Vector3.Distance(transform.position, t.position);
                seesPlayer = !Physics.Raycast(transform.position, dir, dist, blockMask);
            }
            else
            {
                seesPlayer = false;
            }
        }
        else
        {
            seesPlayer = false;
        }
    }

    void Shoot()
    {
        nav.speed = 0;
        anim.SetBool("Run", false);
        anim.SetBool("Shoot", true);
        transform.LookAt(target);
        flash.Play();
        PoolManager.Instance.ReuseObject(projectilePrefab, firePoint.position, firePoint.rotation);
        AudioManager.instance.Play("Pistol1911");
    }

    public void Die()
    {
        dead = true;
        StopCoroutine(visionRoutine);
        hitbox.enabled = false;
        anim.enabled = false;
        hellWeapon.transform.SetParent(null);
        hellWeapon.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.None;
        hellWeapon.GetComponent<PickUpWeaponController>().enabled = true;
        hellWeapon.GetComponent<BoxCollider>().enabled = true;
        GameManager.Score(100);
        GameManager.CheckForWin();
        enabled = false;
    }
}
                        

using UnityEngine;

public class Piano : MonoBehaviour
{
    public AudioClip[] notes;
    public float rayLength = 2f;
    private int layerMask;
    // Start is called before the first frame update
    void Start()
    {
        layerMask = 1 << LayerMask.NameToLayer("PianoKey");
    }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hitInfo;

            if (Physics.Raycast(ray, out hitInfo, rayLength, layerMask))
            {
                PianoKeys key = hitInfo.collider.gameObject.GetComponent<PianoKeys>();
                if (key != null)
                {
                    key.SetPressed(true);
                    int noteIndex = key.noteIndex;
                    if (noteIndex >= 0 && noteIndex < notes.Length)
                    {
                        AudioSource audioSource = GetComponent<AudioSource>();
                        audioSource.clip = notes[noteIndex];
                        audioSource.Play();
                    }
                }
            }
        }
        else if (Input.GetMouseButtonUp(0))
        {
            foreach (PianoKeys key in GetComponentsInChildren<PianoKeys>())
            {
                key.SetPressed(false);
            }
        }
    }
}
                        

Pricing

I offer two types of pricing, see below

Consultation

$15/hr
  • Code Review
  • Planning
  • Bug Fixing
Contact

Everything Else

Custom
  • Flat Rate per Milestone
  • Flexible Pricing starting at $5
  • Long-term Support
Contact