What is Game Engine ?
What is Game Engine ?
Game Engines යනු video games නිර්මාණය කිරීම සඳහා අත්යවශ්ය tools සහ සංරචක සපයන මෘදුකාංග රාමුවකි.
එය පදනමක් ලෙස ක්රියා කරන අතර, ක්රීඩා නිර්මාණයේ තාක්ෂණික අංශ බොහොමයක් හසුරුවන අතර, ක්රීඩා ක්රීඩාව, stories සහ arts යන නිර්මාණාත්මක අංශ කෙරෙහි අවධානය යොමු කිරීමට සංවර්ධකයින්ට ඉඩ සලසයි.
Populare Game Engines,
Unreal Engine
Unity
Godot Engine
CryEngine
GameMaker Studio 2
Construct
RPG Maker
Amazon Lumberyard
Cocos2d
Gamebryo
FPS Game එකක් සාදමු
Game Engine : Unity
C# Scripts ,
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(CharacterController))]
public class playercontrol : MonoBehaviour {
public float speed = 3.0F;
public float rotateSpeed = 3.0F;
void Update()
{
CharacterController controller = GetComponent<CharacterController>();
transform.Rotate(0, Input.GetAxis("Horizontal") * rotateSpeed, 0);
Vector3 forward = transform.TransformDirection(Vector3.forward);
float curSpeed = speed * Input.GetAxis("Vertical");
controller.SimpleMove(forward * curSpeed);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class cameracontrol : MonoBehaviour
{
public GameObject player;
public float xSensitivity = 10;
public float ySensitivity = 10;
public float smoothing = 0.4f;
public int min = -60;
public int max = 60;
private float mouseOffsetY;
private float mouseOffsetX;
private float xtargetRotation = 10;
private float ytargetRotation = 10;
void Update()
{
mouseOffsetY = Input.GetAxis("Mouse Y") * ySensitivity;
ytargetRotation += -mouseOffsetY;
ytargetRotation = ytargetRotation % 360;
ytargetRotation = Mathf.Clamp(ytargetRotation, min, max);
mouseOffsetX = Input.GetAxis("Mouse X") * xSensitivity;
xtargetRotation += mouseOffsetX;
xtargetRotation = xtargetRotation % 360;
transform.localRotation = Quaternion.Lerp(transform.localRotation, Quaternion.Euler(ytargetRotation, 0, 0), Time.deltaTime * 10 / smoothing);
player.transform.rotation = Quaternion.Lerp(player.transform.rotation, Quaternion.Euler(0, xtargetRotation, 0), Time.deltaTime * 10 / smoothing);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class shoot : MonoBehaviour
{
public float damage = 10f;
public float range = 100f;
public Camera fpsCam;
public Text countText;
private int count;
void Start()
{
count = 0;
SetCountText();
}
void Update()
{
if (Input.GetButtonDown("Fire1"))
{
Shoot();
}
}
void Shoot()
{
RaycastHit hit;
if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
{
target Target = hit.transform.GetComponent<target>();
if (Target != null)
{
Target.TakeDamage(damage);
count = count + 1;
SetCountText();
}
}
}
void SetCountText()
{
countText.text = "SCORE :- " + count.ToString();
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class target : MonoBehaviour {
public float health = 50f;
public void TakeDamage(float amount)
{
health -= amount;
if (health <= 0f)
{
Die();
}
}
void Die()
{
Destroy(gameObject);
}
}
Car Game එකක් සාදමු
Game Engine : Unity
Unity වලින් simple car game එකක් හදන විහිහ අද්යනය කරමු ,
1. Project එකක් සෑදීම:
- Unity Hub එක විවෘත කර, "New Project" තෝරන්න.
- 3D Template එක තෝරාගන්න.
- Project එකට නමක් දී "Create" කරන්න.
2. Scene එකක් සකස් කිරීම:
- Hierarchy window එකේ "Create" > "3D Object" > "Plane" තෝරන්න. මෙය ඔබේ හඳුනාගත් භූමිය වනු ඇත.
- Plane එකට "Ground" යන නම දෙන්න.
- Plane එකට colours ලබාදීම සඳහා Material එකක් Create කර, ඒක Plane එකට add කරන්න.
3. Car Model එකක් Import කිරීම:
- Free Asset Store එකෙන් හෝ Unity Asset Store එකෙන් Car Model එකක් import කරන්න.
- Car Model එක Scene එකට Drag & Drop කරන්න.
- Car Model එක "Car" යන නමට වෙනස් කරන්න.
4. Car Controller සකස් කිරීම:
- Car GameObject එකට "Rigidbody" Component එක එකතු කරන්න.
- Car Object එකට "Box Collider" Component එකක් එකතු කරන්න.
- Scripts ෆෝල්ඩරයක් සෑදීම:
using UnityEngine;
public class CarController : MonoBehaviour
{
public float speed = 10.0f;
public float turnSpeed = 50.0f;
void Update()
{
float move = Input.GetAxis("Vertical") * speed * Time.deltaTime;
float turn = Input.GetAxis("Horizontal") * turnSpeed * Time.deltaTime;
transform.Translate(0, 0, move);
transform.Rotate(0, turn, 0);
}
}
- මෙම script එක Save කර, Car GameObject එකට Drag & Drop කරන්න.
5. Camera Follow සකස් කිරීම:
- Main Camera එක Car Object එකට add කරන්න.
- Simple follow script එකක් සෑදීම:
using UnityEngine;
public class CameraFollow : MonoBehaviour
{
public Transform target;
public float distance = 10.0f;
public float height = 5.0f;
void LateUpdate()
{
Vector3 newPos = target.position - target.forward * distance + Vector3.up * height;
transform.position = newPos;
transform.LookAt(target);
}
}
- මෙම script එක Save කර, Main Camera එකට Drag & Drop කරන්න.
- Main Camera GameObject එකේ CameraFollow script එකට Car Object එක Drag & Drop කරන්න.
6. Game එක Run කිරීම:
- Play Button එක Click කර, game එක test කරන්න.
මෙය ඉතාම සරල car game එකක් සෑදීමේ පියවර වන අතර ඔබට අවශ්ය ලෙස පහත සඳහන් Improved කොටස දිගහැර එහි ඇති පරිදි Game එක වැඩිදියුණු කල හැක.
New Tutorials Coming Soon !
. . .