Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
sharad0111 authored Dec 22, 2021
1 parent b015d24 commit 4d08f52
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Assets/Scripts/CarController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

public class CarController : MonoBehaviour
{
public Rigidbody2D frontTireRb, backTireRb, carRb;
public float speed = 15f;
public float carTorque = 10f;
float horizontalInput;
void Update()
{
horizontalInput = Input.GetAxis("Horizontal");
}
private void FixedUpdate()
{
backTireRb.AddTorque(-horizontalInput * speed * Time.fixedDeltaTime);
backTireRb.AddTorque(-horizontalInput * speed * Time.fixedDeltaTime);
carRb.AddTorque(-horizontalInput * carTorque * Time.fixedDeltaTime);
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/CarController.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4d08f52

Please sign in to comment.