Author Topic: [function] Player collides with brick  (Read 1313 times)

Lies.
Code: [Select]
function FXDtsBrick::onPlayertouch(%this,%obj,%col)
{
if($Debug_OPT){
if(isobject(%obj.client)){
announce("killing.");
%obj.kill();
}else{
announce("not killing.");
}
   parent::onPlayerTouch(%this,%obj,%col);
}

I put this into a package which is enabled, turned on $debug_OPT, and spawned 2 2x2 bricks.
One has an onplayertouch event. The other does not. The evented one kills me, the other does not. Also for the record the onplayertouch event is not player>kill.
Maybe it only works if the brick has any events. onBotTouch and onTeamXPlayerTouch events are only called through onPlayerTouch - yet I can spawn bricks with those events and they work fine with or without extra onPlayerTouch events.

Try it with a 2x2 with an onActivate event, I think it'll work.

Wouldn't you just fall through any and all terrain?
Terrain-collisions use onImpact
« Last Edit: September 14, 2009, 08:14:35 PM by Kalphiter »

I mean terrain made of bricks. Like, for any decent deathmatch.

The name of the variables don't matter, just the number of them and how you use them.
Example:
in a package
function Armor::onCollision(%turkey, %ham, %bacon, %fryer, %degrees)

Would work the same as:
in a package
function Armor::onCollision(%this,%obj,%col,%vec,%speed)

As long as you know that:
%turkey/%this is the datablock.
%ham/%obj is the player.
%bacon/%col is what they touched.
%fryer/%vec is the direction they're moving in.
%degrees/%speed is how fast they were going.

Second question: Yes. But if normal onCollision stuff stop working, add Parent::onCollision(stuff...) to it.
A package wont be needed for this one.

The name of the variables don't matter, just the number of them and how you use them.
Example:
in a package
function Armor::onCollision(%turkey, %ham, %bacon, %fryer, %degrees)

Would work the same as:
in a package
function Armor::onCollision(%this,%obj,%col,%vec,%speed)

As long as you know that:
%turkey/%this is the datablock.
%ham/%obj is the player.
%bacon/%col is what they touched.
%fryer/%vec is the direction they're moving in.
%degrees/%speed is how fast they were going.
but how do I know how many variables I need and what they stand for?

but how do I know how many variables I need and what they stand for?
The best way is to call your variables %a,%b,%c etc and echo all their class names to find out what type of object they are.

but how do I know how many variables I need and what they stand for?
A great source is v0002.
Ontop of that, I just gave you all 5 of them.

Terrain-collisions don't use onImpact
Oops, accidentally put "don't"

Yeah, thanks for the oncollision code, chrono

What is the function to get the class names and the object type?