gameobject lists-> which&when [message #457023] |
Thu, 06 October 2011 17:34 |
robbyke
Messages: 348 Registered: September 2010 Location: Belgium
Karma: 0
|
Recruit |
|
|
with the way with the object lists i cant find out wich to use.
my problem :
created object.
attached a script
find out if soldier is near object with attached script
that last step wont work ive tried out some lists but im doubting if i can still find my newly created object like this or maybe i first have to see under wich class its now divided
Owner of kambot TT server
kambot.freeforums.org
|
|
|
|
Re: gameobject lists-> which&when [message #457061 is a reply to message #457025] |
Fri, 07 October 2011 06:32 |
|
This code will work better
#include "GameObjManager.h"
#include "SoldierGameObj.h"
GameObject *Get_Nearest_Solider(GameObject *obj) // Get the nearest solider next to a object
{
float closestdist = FLT_MAX;
Vector3 obj_pos = Commands->Get_Position(obj);
SmartGameObj *object = 0;
for (SLNode<SmartGameObj>* node = GameObjManager::SmartGameObjList.Head(); node; node = node->Next())
{
SmartGameObj* object = node->Data();
if (o && o->As_SoldierGameObj())
{
Vector3 player_pos = Commands->Get_Position(o);
float dist = Commands->Get_Distance(player_pos,obj_pos);
if (dist < closestdist)
{
closestdist = dist;
object = o;
}
}
}
return object;
}
That code will find the closest soldier to the passed in object.
The SmartGameObjList is for soldiers and vehicles and should be used in this case as you will have less objects to check.
Jonathan Wilson aka Jonwil
Creator and Lead Coder of the Custom scripts.dll
Renegade Engine Guru
Creator and Lead Coder of TT.DLL
Official member of Tiberian Technologies
|
|
|
Re: gameobject lists-> which&when [message #457081 is a reply to message #457023] |
Fri, 07 October 2011 10:58 |
robbyke
Messages: 348 Registered: September 2010 Location: Belgium
Karma: 0
|
Recruit |
|
|
i had to use the first one i had to check if there was an object nearby with a certain script attached ive found it now. i checked if my obj was a veh or a soldier and i shouldnt have done that
Owner of kambot TT server
kambot.freeforums.org
|
|
|
Re: gameobject lists-> which&when [message #457120 is a reply to message #457061] |
Fri, 07 October 2011 18:08 |
|
Gen_Blacky
Messages: 3250 Registered: September 2006
Karma: 1
|
General (3 Stars) |
|
|
jonwil wrote on Fri, 07 October 2011 06:32 |
The SmartGameObjList is for soldiers and vehicles and should be used in this case as you will have less objects to check.
|
Ah okay, So if I was looking for a building gameobject I would use BuildingGameObjList.
|
|
|