Thursday, 23 June 2016

Unity3D Need for Speed Car Movement - Mapping Tires on WheelColliders

This Tutorial Includes the Rotation of the Tires (Spinning and steering animation).

Download the Tire Mapping Script



The Tires will move exactly like the WheelColliders, the spin, steer and also the position will map exactly on the WheelColliders.

Subscribe to my YouTube Channel for more videos like this.

             

Unity3D Need for Speed Car Movement - Camera Controls

Copy the below code and paste it into a c# file in Unity3D
named cameraController.

Also Check out my Video on YouTube


using UnityEngine; using System.Collections; public class cameraController : MonoBehaviour { public Transform car; public float distance = 6.4f; public float height = 1.4f; public float rotationDamping = 3.0f; public float heightDamping = 2.0f; public float zoomRatio = 0.5f; public float defaultFOV = 60f; private Vector3 rotationVector; void LateUpdate(){ if(car != null){ float wantedAngle = rotationVector.y; float wantedHeight = car.position.y + height; //car.position.y + height; float myAngle = transform.eulerAngles.y; float myHeight = transform.position.y; myAngle = Mathf.LerpAngle(myAngle, wantedAngle, rotationDamping*Time.deltaTime); myHeight = Mathf.Lerp(myHeight, wantedHeight, heightDamping*Time.deltaTime); Quaternion currentRotation = Quaternion.Euler(0, myAngle, 0); transform.position = car.position; transform.position -= currentRotation*Vector3.forward*distance; Vector3 temp = transform.position; //temporary variable so Unity doesn't complain temp.y = myHeight; transform.position = temp; transform.LookAt(car); } } void FixedUpdate() { if(car != null){ Vector3 localVelocity = car.InverseTransformDirection(car.GetComponent<Rigidbody>().velocity); if (localVelocity.z < -10.5f) { Vector3 temp = rotationVector; //because temporary variables seem to be removed after a closing bracket "}" we can use the same variable name multiple times. temp.y = car.eulerAngles.y + 180; rotationVector = temp; } else { Vector3 temp = rotationVector; temp.y = car.eulerAngles.y; rotationVector = temp; } float acc = car.GetComponent<Rigidbody>().velocity.magnitude; GetComponent<Camera>().fieldOfView = defaultFOV + acc * zoomRatio * Time.deltaTime; } } }

This code is inspired from a javascript version of the below video

#4 How to make a Car game - Unity 3D Tutorial - Car Camera
Go check out this video for total explanation of this code.

             

Friday, 17 June 2016

Unity3D Need for Speed Car Movement - Movement Controls

In this Article I am going to be providing you the download links of the Terrain and Scripts.

1. Movement Controls Script

2. Terrain Prefab 


Follow the YouTube Channel to learn How To Create Need For Speed Car Movement in Unity3D.

The next video will be delivering Decelerating Speed Automatically and Camera Control for the vehicle.

Stay Tuned.

             

Setting up Wheel Colliders on Vehicle - Unity3D

This is the First Article in this Series, in which I am going to be teaching you How to create Need For Speed Car Movement in Unity3D.

Follow the YouTube Channel to learn How To Create Need For Speed Car Movement in Unity3D.


1) Create a New Project and Download the Car Package

2) Import the Package in your Unity3D Project and Drag the Prefab on the hierarchy.

3) Download the Textures of the Wheels and Alloy Rim and save it in the Textures Folder in your project.

4) Follow the Video on YouTube to See how to Setup Wheel Colliders Perfectly.

5) List of Cars @TURBOSQUID











These are some of the cars, that i recommended. You can search on the TurboSquid for more vehicles.

What you need to see while selecting one of the Model is that the Polygons. If you are creating a game for Mobile Devices then I prefer to use cars less than 5000 Polygons. You can also download it and modify it on Blender or 3Dmax and decrease some of the polygons.

I Have download a Car which was 60000 Polygons and decreased it to 4000 polygons, but cannot sell it because I am not the owner of the model. So if you want a video on how to decrease polygons of cars without making it look dull then do text or comment on this, I will make a series on that too.

             

Tuesday, 14 June 2016

How to Create Need For Speed Car Movement in Unity3d

This is going to be a tutorial series, in this tutorial series you are going to learn How to create NFS Car Movement in unity3D. In this article you will learn, what is it going to look in the end when the game is finished, a final Demo

This series will be on video/audio and written basis, so if you have any problem with the code, all the code will be delivered here, the models and other things will be published here, so don't forget to follow this blog, so you will get the first notification when a new article is published. Also subscribe the YouTube channel for video/audio tutorial.



What are you going to learn in this tutorial series?

1) Need for Speed Car Movement.
2) Skid movement.
3) Weapons integration, like, Rocket Launcher, Mine Drop, Machine Gun. 
4) Camera Integration, like, Top Camera, Rear Camera, Gun Camera.
4) Special effects, like, Explosion Effect, Collision Effects, skid marks, smoke effect.
5) Keyboard and Touch Controls.
6) PC/Mobile Optimisation.
7) Police Chase our car (without nav mesh).
8) Moving Miscellaneous Cars with mobile optimised.
9) Unity3D Folders Management.  

What are you going to get from this tutorial series?

1) Full Map prefab with model.
2) Lamps, post box Prefabs with model.
3) 4 Cars Models and Prefabs with Weapon Integration.
4) Gun Models
5) UI images.
6) Material, Textures and other.