Skip to content

DaBaiHao/Cthulhu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cthulhu

Cthulhu is a RPG game, and implement with unity.



Descrpition

  • Game type: RPG, 3D
  • Platform: Unity3D


Background

The Background story of this game is based on the The Call of Cthulhu, which is a short story by American writer H. P. Lovecraft.

H. P. Lovecraft

Main character prototype based on Francis Wayland Thurston who is the a character in The Call of Cthulhu.



Character Setting

Main Character 1

Main Character 2



Current stage

  • Player movement Complete
  • User interface Complete
  • Environment
  • making WindMill rotating Complete
  • WindMill
  • Enemy Path Finding Complete
  • Pathfinding
  • Fully Event Based Raycasting


Coding Information

1. About WindMill rotating

WindMill

Based on the code below in file SpinMe.cs :

float xDegreesPerFrame = Time.deltaTime / 60 * 360 * xRotationsPerMinute;
transform.RotateAround(transform.position, transform.right, xDegreesPerFrame);
float yDegreesPerFrame = Time.deltaTime / 60 * 360 * yRotationsPerMinute;
transform.RotateAround(transform.position, transform.up, yDegreesPerFrame);
float zDegreesPerFrame = Time.deltaTime / 60 * 360 * zRotationsPerMinute;
transform.RotateAround(transform.position, transform.forward, zDegreesPerFrame);

2. About Enemy Path finding

Pathfinding

  1. Using Nevigation and PathFinding( AI tool ) in Unity to find walkable ground in the environment item.

Enemy

pathingFinding

  1. Add nav mesh agent and AI character control functions
  2. using the nav mesh agent and AI character control functions in Enemy.cs:
if(distanceToPlayer <= attackRadius)
      {
           aiCharacterControl.SetTarget(player.transform);
       }
       else
       {
           aiCharacterControl.SetTarget(transform);
       }

The enemy will stop when player character run away.

ai


3. Fully Event Based Raycasting

4. Player Path finding

  1. Using Nevigation and PathFinding( AI tool ) in Unity to find walkable ground in the environment item.
  2. using the nav mesh agent and AI character control functions in PlayerMovement.cs:
switch (layerHit)
        {
            case enemyLayerNumber:
                // navigate to the enemy
                GameObject enemy = raycastHit.collider.gameObject;
                aiCharacterControl.SetTarget(enemy.transform);
                break;
            case walkableLayerNumber:
                // navigate to point on the ground
                walkTarget.transform.position = raycastHit.point;
                aiCharacterControl.SetTarget(walkTarget.transform);
                break;
            default:
                Debug.LogWarning("Don't know how to handle mouse click for player movement");
                return;
        }
  1. The player will find the enemy after click the target one:

playerPathfinding

About

Test game

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published