Author Topic: Detecting an item object using onTrigger?  (Read 2916 times)

This is from click push:
Code: [Select]
function Player::activateStuff(%player)
{
%v = Parent::activateStuff(%player);
%client = %player.client;

if(!$ClickPush::Status || (!%client.isAdmin && $ClickPush::AdminOnly))
return %v;

%target = containerRayCast(%player.getEyePoint(),vectorAdd(vectorScale(vectorNormalize(%player.getEyeVector()),2),%player.getEyePoint()),$TypeMasks::PlayerObjectType,%player);

if(!isObject(%target) || %target == %player || %player.getObjectMount() == %target)
return %v;

%target.setVelocity(vectorAdd(%target.getVelocity(),vectorScale(%player.getEyeVector(),$ClickPush::Amount)));

return %v;
}

It detects if the target is a player, but I want it to detect if the target is an item, and fling it towards them instead of away.  
How do you detect if the object is an item?  And how do you fling it towards the player? 
If I want a larger radius of detection than the size of the item, would I need to use a raycast instead of this line of sight from clickpush?
« Last Edit: February 09, 2015, 09:00:57 PM by Rogue »

To detect if it's an item, change the typemask to $TypeMasks::ItemObjectType.
If I want a larger radius of detection than the size of the item, would I need to use a raycast instead of this line of sight from clickpush?
It is using a raycast. A raycast is just one, tiny, straight, line of detection.

I'd suggest reading THIS tutorial.
« Last Edit: February 09, 2015, 09:59:02 PM by jes00 »

Thanks Jes, that's quite a helpful tutorial.

How would I use function WeaponImage::onUnMount and WeaponImage::onMount for ALL WeaponImages? 
i.e. not item specific, but as a detection method for when any item is equipped.

Thanks Jes, that's quite a helpful tutorial.

How would I use function WeaponImage::onUnMount and WeaponImage::onMount for ALL WeaponImages? 
i.e. not item specific, but as a detection method for when any item is equipped.
You just answered your own question. Use weaponImage.

You just answered your own question. Use weaponImage.
WeaponImage is a placeholder in this example, for the image data block name if i'm not mistaken.  ie.. gunWeaponimage and so on

WeaponImage is a placeholder in this example, for the image data block name if i'm not mistaken.  ie.. gunWeaponimage and so on
WeaponImage::onWhatever is called for all weapon images because it's the class name of GunWeaponImage.