Author Topic: Raycast Help  (Read 3875 times)

No you aren't sure?
No I am not sure. I am not sure exactly how point raycasts work because I never use them, nor am I sure what you're asking

What are you talking about? If the raycast collides with anything other than a player, I believe it returns 0. A raycast doesn't magically go through objects (besides possibly bricks with raycasting turned off).
Right, that's what I thought at least. But zeblote just said that raycasts ignore objects that don't match the typemasks. Since the statements of both of you are contradictory, one of you is wrong. We can all assume I'm wrong in some respect, too

Right, that's what I thought at least. But zeblote just said that raycasts ignore objects that don't match the typemasks. Since the statements of both of you are contradictory, one of you is wrong. We can all assume I'm wrong in some respect, too

I think he meant ignore, as in returns 0 or doesn't return the actual object the raycast collided with.

A raycast is not physical. It does not "hit" things. You need to specify typemasks of objects it is to check.

A raycast is not physical. It does not "hit" things. You need to specify typemasks of objects it is to check.

If I were to do a raycast between the player and the found player for everything besides a player typemask. It would return true if there was something in between them, right?

Correct. By setting the raycast to ignore the player object Typemask, it will return 0 unless it strikes something other than a player. When it does detect something, it will return the object's ID.

What in the world is it with people not understanding raycasts? They simply return the object, normal vector and position of the first surface intersected by traversing from A to B while ignoring anything that doesn't match the typemask with a logical AND; if nothing is hit, it returns 0.

What could possibly be unclear about that?

What in the world is it with people not understanding raycasts? They simply return the object, normal vector and position of the first surface intersected by traversing from A to B while ignoring anything that doesn't match the typemask with a logical AND; if nothing is hit, it returns 0.

What could possibly be unclear about that?
Everyone learns things differently at different rates, so there's no point in wondering why they don't get it. Either it hasn't yet been explained in a way they can understand, or they'll never really get it. And for others, it just clicks.

Code: [Select]
package Chat
{
function serverCmdMessageSent(%client, %msg)
{
%position = %client.player.position;
InitContainerRadiusSearch(%position,30,$TypeMasks::PlayerObjectType);

while((%targetObject=containerSearchNext()) !$= 0)
{
if((ContainerRayCast(%position, %targetObject.player, $TypeMasks::)))
{
%c = %targetObject.client;
messageClient(%c,'',"\c4[Local] \c7" SPC %client.clanprefix @ "\c3" @ %client.name @ "\c7" @ %client.clansuffix @ "\c6:" SPC %msg);
}
}
}
};


So what would the parameters be for that ContainerRayCast? I think the positions are right but I don't know about the typeMasks.

Instead of using every single one other than player and checking if it doesn't hit anything, just do $typemasks::all and check if it hits the player.

For future reference, you can combine typemasks with "|", eg "$typemasks::PlayerObjectType | $typemasks::fxBrickObjectType" will only detect bricks and players (I'm not sure of the name of the brick typemask on the top of my head, but you get the idea).

Or you could just use the last optional parameter, the exempt typemask, so that it looks through players. More like so:
Code: [Select]
package Chat
{
function serverCmdMessageSent(%client, %msg)
{
%position = %client.player.position;
InitContainerRadiusSearch(%position,30,$TypeMasks::PlayerObjectType);

while((%targetObject=containerSearchNext()) !$= 0)
{
                        //This needs to be if(false), because you don't want the msg to reach the target if it encounters something. The first Typemask argument are/is the Typemask(s) that will be searched for. The second Typemask argument are/is the Typemask(s) that will be ignored (allowing you to talk through people).
if(!ContainerRayCast(%position, %targetObject.player, $TypeMasks::All, $TypeMasks::PlayerObjectType))
{
%c = %targetObject.client;
messageClient(%c,'',"\c4[Local] \c7" SPC %client.clanprefix @ "\c3" @ %client.name @ "\c7" @ %client.clansuffix @ "\c6:" SPC %msg);
}
}
}
};

Or you could just use the last optional parameter, the exempt typemask, so that it looks through players. More like so:

Ok that's exactly what I was thinking. Thanks

EDIT: Nope that doesn't work. It works at one point then breaks for some reason.
« Last Edit: October 09, 2013, 07:32:08 PM by devildogelite »

Try replacing %targetObject.player with %targetObject.getPosition().
« Last Edit: October 10, 2013, 01:30:24 AM by BluetoothBoy »

Im pretty sure the "exempt" parameter is only for a single object, not a typemask. I may be wrong though.

Try replacing %targetObject.player with %targetObject.getPosition().

yes

Im pretty sure the "exempt" parameter is only for a single object, not a typemask. I may be wrong though.

yes
But you can have multiple exempts by adding them as more args

Ah yes, that is correct. Why I thought it was a Typemask instead is beyond me.