VIT Bhopal CSE (Specialization In Gaming Technology)
Project Natural Vision
Members:
- Ronak Sharma (20BCG10004)
- Yashasvee Iyer (20BCG10012)
Main Effect: Wind Effect
Extra: Made terrain, added textures, Trees, Audio, and build an application.
Link To Showcase Video - (https://drive.google.com/file/d/12m1VCsFkd4sdExSAlLP4-xb7xzi5SWrC/view?usp=shari...)
- Assets Used
Tree Asset -(https://assetstore.unity.com/packages/3d/vegetation/trees/conifers-botd-142076)
Groud Texture -(https://assetstore.unity.com/packages/2d/textures-materials/floors/outdoor-groun...)
Terrain Tools -(https://assetstore.unity.com/packages/2d/textures-materials/nature/terrain-tools...)
SkyBox -(https://assetstore.unity.com/packages/2d/textures-materials/sky/skybox-series-fr...)
- Open Unity and add a terrain from the 3D objects menu.
- Select the brush after selecting the raise and lower terrain in the drop-down menu shown in the image below.
- Make the terrain by raising and lowering the height of the terrain with different types of brushes.
- Add layer
- Add a layer as per your choice (Note: Layer must be already added in your assets)
- Paint the textures.
- Now add more layers for making roads.
- Select layer.
- Draw road with the brush.
- Select the tree option shown in the image.
- Click on add Tree.
- Select a tree. (Trees must already be available in your assets, you can download it from the asset store or create one with the help of blender).
- Add trees by using the brush on the terrain. We can also adjust the density of trees and the size of the brush.
- Create an empty game object.
- Create a capsule.
- Add the capsule into the empty object.
- Remove capsule collider.
- Add the main camera into the system of the empty object.
- Now position the empty game object.
- Now create an empty C# Script.
- Open the C# script in your code editor.
- Write the below code.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(CharacterController))]
public class SC_FPSController : MonoBehaviour
{
public float walkingSpeed = 7.5f;
public float runningSpeed = 11.5f;
public float jumpSpeed = 8.0f;
public float gravity = 20.0f;
public Camera playerCamera;
public float lookSpeed = 2.0f;
public float lookXLimit = 45.0f;
CharacterController characterController;
Vector3 moveDirection = Vector3.zero;
float rotationX = 0;
[HideInInspector]
public bool canMove = true;
void Start()
{
characterController = GetComponent<CharacterController>();
// Lock cursor
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
void Update()
{
// We are grounded, so recalculate move direction based on axes
Vector3 forward = transform.TransformDirection(Vector3.forward);
Vector3 right = transform.TransformDirection(Vector3.right);
// Press Left Shift to run
bool isRunning = Input.GetKey(KeyCode.LeftShift);
float curSpeedX = canMove ? (isRunning ? runningSpeed : walkingSpeed) * Input.GetAxis("Vertical") : 0;
float curSpeedY = canMove ? (isRunning ? runningSpeed : walkingSpeed) * Input.GetAxis("Horizontal") : 0;
float movementDirectionY = moveDirection.y;
moveDirection = (forward * curSpeedX) + (right * curSpeedY);
if (Input.GetButton("Jump") && canMove && characterController.isGrounded)
{
moveDirection.y = jumpSpeed;
}
else
{
moveDirection.y = movementDirectionY;
}
// Apply gravity. Gravity is multiplied by deltaTime twice (once here, and once below
// when the moveDirection is multiplied by deltaTime). This is because gravity should be applied
// as an acceleration (ms^-2)
if (!characterController.isGrounded)
{
moveDirection.y -= gravity * Time.deltaTime;
}
// Move the controller
characterController.Move(moveDirection * Time.deltaTime);
// Player and Camera rotation
if (canMove)
{
rotationX += -Input.GetAxis("Mouse Y") * lookSpeed;
rotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit);
playerCamera.transform.localRotation = Quaternion.Euler(rotationX, 0, 0);
transform.rotation *= Quaternion.Euler(0, Input.GetAxis("Mouse X") * lookSpeed, 0);
}
}
}
- Now add the Script in the empty object, it will give the player some controls.
- Go to window>Rendering>Lighting.
- Then open environment.
- Click on Skybox material and select a preferred skybox material (Note: Skybox material must be already available in your assets, we downloaded it from the asset store).
- Right-click on the empty object > Audio > Audio Source.
- Choose audio track
- Enter Wind Effect
- Click on Build
- Choose Necessary Settings