Game Development Community

Getting a player to detect objects around them

by Drew Kario · in Torque Game Engine Advanced · 08/10/2009 (5:34 pm) · 2 replies

Hi guys. Im stumped on this.

What im trying to do is make it so the player searches for an object around it in a radius, and when it does, to toggle the visibility of one of the gui's i have set up for this. Now, ive made sure the gui's work but i cant seem to make any headway on this problem.

This is what i have put together so far, by searching the forums and resources, and tdn, and referencing and lots of stuff like that.
Im using AFX combopack as well, if that matters.
Ive stuck this into player.cs right after the end of the datablocks.
function PlayerData::processTick(%this, %player)
{
   
echo ("test for ticks");
%position = localclientconnection.player.getPosition();
InitContainerRadiusSearch ( %position , 10 , ItemObjectType );
echo("Initializing Search");
%obj = ContainerSearchNext();
echo("Results: " @ %obj);
if(%obj.getClassName()  $= "popupgui")
   {
	if (%obj.getSubClassName() $= "weapon")
		weapongui.Visible = true;
	else
		weapongui.Visible = false;
   }
}

I'm not even getting the echo in this, so im sure i missed something somwhere.

Someone help?

#1
08/12/2009 (3:36 pm)
When you say you're not even getting the echo I assume you mean the very first one, so the function isn't being called? You implemented this in Script?

I'm not sure that there is a ProcessTick callback into script from the engine, you might have to write that part.
#2
08/16/2009 (8:33 pm)
that sounds a bit too complex. Umm.. Is there a way to set a timer? So that when oncollision happens it sets up like a 2 tick timer before it decides to execute the function, and if the player remains in the same area the timer is never able to count down?