Untitled

 avatar
unknown
plain_text
19 days ago
824 B
4
Indexable
using UnityEngine;

public class HockeyPlayer : MonoBehaviour
{
    public float speed = 12f;
    public float turnSpeed = 100f;
    private Rigidbody rb;

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

    void FixedUpdate()
    {
        float move = Input.GetAxis("Vertical");
        float turn = Input.GetAxis("Horizontal");

        Vector3 movement = transform.forward * move * speed;
        rb.AddForce(movement);

        transform.Rotate(0, turn * turnSpeed * Time.deltaTime, 0);
    }
}
PUCK SHOOTING
public class ShootPuck : MonoBehaviour
{
    public Rigidbody puck;
    public float shotPower = 30f;

    void Update()
    {
        if(Input.GetKeyDown(KeyCode.Space))
        {
            puck.AddForce(transform.forward * shotPower,
            ForceMode.Impulse);
        }
    }
}
Editor is loading...
Leave a Comment