Author Topic: When A Player Steps Off A Brick  (Read 1018 times)

How can I detect when a player is no longer in contact with a brick?

Either use zones or a schedule which is cancelled and rescheduled every time you touch a brick.

Either use zones or a schedule which is cancelled and rescheduled every time you touch a brick.
This is coding help, not eventing.
or a schedule which is cancelled and rescheduled every time you touch a brick.
Explain please.

This is coding help, not eventing.

Zones are not events.

Explain please.

function fxDTSBrick::stopTouch( %this, %pl )
{
   // do something
}




When %pl (player) touches %obj (brick):

  • cancel( %obj.stopTouch[ %pl ] );
  • %obj.stopTouch[ %pl ] = %obj.schedule( tolerance, "stopTouch", %pl );


Care to explain?
if you don't know, events are coded by.. well, torque code. therefore, the zones created via someone's zone mod are not actually being created by the events, they're being created by code. you can make zones without events. if you want to know how i suggest you look at the zone events script, it'll probably help.

function fxDTSBrick::stopTouch( %this, %pl )
{
   // do something
}




When %pl (player) touches %obj (brick):

  • cancel( %obj.stopTouch[ %pl ] );
  • %obj.stopTouch[ %pl ] = %obj.schedule( tolerance, "stopTouch", %pl );
So like this?

Code: [Select]
package Blah
{
function FxDTSBrick::stopTouch(%obj, %player)
{
%player.isTouchin[%obj] = false;
}

function FxDTSBrick::onPlayerTouch(%obj, %player)
{
parent::onPlayerTouch(%obj, %player);


%player.isTouchin[%obj] = true;

cancel(%obj.stopTouch[%player]);

%obj.stopTouch[%player] = %obj.schedule(50, "stopTouch", %player);
}
};
activatePackage(Blah);
Then to check if their not touching the brick I can do if(!%player.isTouchin[%obj]) right?

So like this?

Code: [Select]
Then to check if their not touching the brick I can do if(!%player.isTouchin[%obj]) right?

Essentially. You don't need to package fxDTSBrick::stopTouch though.

You don't need to package fxDTSBrick::stopTouch though.
I know.
Essentially.
Not working : /

Code: [Select]
registerInputEvent("FxDTSBrick","onPlayerFirstTouch","Self fxDTSBrick" TAB "Player Player" TAB "Client GameConnection" TAB "MiniGame MiniGame");

package onPlayerFirstTouch
{
function FxDTSBrick::stopTouch(%obj, %player)
{
%player.isTouchin[%obj] = false;
}

function FxDTSBrick::onPlayerTouch(%obj, %player)
{
parent::onPlayerTouch(%obj, %player);


%player.isTouchin[%obj] = true;

cancel(%obj.stopTouch[%player]);

%obj.stopTouch[%player] = %obj.schedule(50, "stopTouch", %player);


if(!%player.isTouchin[%obj])
{
$InputTarget_["Self"] = %obj;
$InputTarget_["Player"] = %player;
$InputTarget_["Client"] = %player.client;

if($Server::LAN)
{
$InputTarget_["MiniGame"] = getMiniGameFromObject(%player.client);
}

else
{
if(getMiniGameFromObject(%this) == getMiniGameFromObject(%player.client))
{
$InputTarget_["MiniGame"] = getMiniGameFromObject(%obj);
}

else
{
$InputTarget_["MiniGame"] = 0;
}
}

%this.processInputEvent(onPlayerFirstTouch, %player.client);
}
}
};
activatePackage(onPlayerFirstTouch);

Code: [Select]
if(!%player.isTouchin[%obj])
{
$InputTarget_["Self"] = %obj;
$InputTarget_["Player"] = %player;
$InputTarget_["Client"] = %player.client;

if($Server::LAN)
{
$InputTarget_["MiniGame"] = getMiniGameFromObject(%player.client);
}

else
{
if(getMiniGameFromObject(%this) == getMiniGameFromObject(%player.client))
{
$InputTarget_["MiniGame"] = getMiniGameFromObject(%obj);
}

else
{
$InputTarget_["MiniGame"] = 0;
}
}

%this.processInputEvent(onPlayerFirstTouch, %player.client);
}
this is never run, the if statement should always return false from
Code: [Select]
%player.isTouchin[%obj] = true;

Code: [Select]
-snip-
this is never run, the if statement should always return false from
Code: [Select]
%player.isTouchin[%obj] = true;
Now it works just like onPlayerTouch though.
Code: [Select]
registerInputEvent("FxDTSBrick","onPlayerFirstTouch","Self fxDTSBrick" TAB "Player Player" TAB "Client GameConnection" TAB "MiniGame MiniGame");

package onPlayerFirstTouch
{
function FxDTSBrick::stopTouch(%obj, %player)
{
%player.isTouchin[%obj] = false;
}

function FxDTSBrick::onPlayerTouch(%obj, %player)
{
parent::onPlayerTouch(%obj, %player);


%player.isTouchin[%obj] = true;

cancel(%obj.stopTouch[%player]);

%obj.stopTouch[%player] = %obj.schedule(50, "stopTouch", %player);


if(%player.isTouchin[%obj])
{
$InputTarget_["Self"] = %obj;
$InputTarget_["Player"] = %player;
$InputTarget_["Client"] = %player.client;

if($Server::LAN)
{
$InputTarget_["MiniGame"] = getMiniGameFromObject(%player.client);
}

else
{
if(getMiniGameFromObject(%this) == getMiniGameFromObject(%player.client))
{
$InputTarget_["MiniGame"] = getMiniGameFromObject(%obj);
}

else
{
$InputTarget_["MiniGame"] = 0;
}
}

%obj.processInputEvent(onPlayerFirstTouch, %player.client);
}
}
};
activatePackage(onPlayerFirstTouch);

50ms is very short. The engine doesn't do ::onCollision calls that rapidly.

50ms is very short. The engine doesn't do ::onCollision calls that rapidly.
So how long should I make it?