Help on creating a new gameObject Collision for geometry based - Hayashikiyoi/SP2_DM2199 GitHub Wiki

#Instructions

Step 1 : #include "GameObject.h"put this in your scene header.

Step 2 : GameObject* object[NUM_GEOMETRY] put this in the private of your class

Step 3 : Initialize your object like how you would initialize your meshlist.

Step 4 : When creating your mesh create your colliders and set position of your mesh. Like this :

object[GEO_DEBUGBOX] = new GameObject("Debug", Vector3(-20, 0, -20));

object[GEO_DEBUGBOX]->setCollider(2, 2);

object[GEO_DEBUGBOX]->updateCurPos();

Step Optional : Is your item moving? If so do this in update(),

object[GEO_DEBUGBOX]->Position.x = xPos //Do the same for y,z if you are moving them

object[GEO_DEBUGBOX]->updateCurPos();

Step 5 : Adding collision/trigger box to player (push player back / activate an item)

static Vector3 prevpos,targetpos;

for (int i = 0; i < NUM_GEOMETRY; ++i) {

if (object[i] && player->trigger(object[i])){

camera.position = prevpos; camera.target = targetpos;}

else{prevpos = camera.position; targetpos = camera.target;}

}

Step 6 : In Render use the objects xyz position for translation

Step 7:(Finally) In Exit() remember to delete your mesh using the same method as step 3.