Rays behaving oddly

I’m having a weird problem with rays, and with the radar, collision, and near sensors, for that matter. I have an empty sending out a ray, which is supposed to change a property from false to true when the ray senses an object that contains a certain property. (this is to simulate a character sensing an enemy: when the character sees a mesh with the “enemy” property the propert “enemy sighted” becomes true.) This doesn’t work. When the ray faces the object with the “enemy” property, nothing happens. I made sure the ray is on the right axis, that the range is good, and that the other object does in fact have an “enemy” property, but nothing happens. When I try it with a radar, near, or collision sensor, or any sensor that detects properties in another object, nothing happens. I hope someone can help me with this…

Thanks.

Hmm, Arowe, I created a simple little .blend showing a pointed box detecting two enemy cylinders. When the pointed tip points in the direction of the enemy, the “detect” property turns true. When the pointed tip does not point towards an enemy “detect” becomes false again.

I hope that’s what you were looking for.

Oh yeah, remember to copy and paste the URL into another webpage. Geocities doesn’t allow hotlinking.

http://www.geocities.com/blender3dsite/Blend/DetectEnemy.zip

Jason Lin

that is what I want, but I tried exactly what you described and it won’t work for me. I can’t dl your file by the way, even when I copy and paste the link it says the site doesn’t exist…

Lol, sorry about that. Try the file again. Just noticed I forgot something int he URL.

Jason Lin

hey arow not sure of your problem but you need to have the object with the near sensor an actor

I know, I had it set as one. Gonna try your example now goldentaiji and see if I can figure out what’s wrong with mine…thanks.

I don’t get it. My logic brick set up is exactly like the one in the demo, all the properties are the right name, and the right axis is set for the ray, but my setup doesn’t work while your demo does. I just don’t get it…

Hmm, that’s strange. The only thing I can think of is that maybe the range is too small, try making it bigger. Make sure it’s on the correct axis as well.

Jason Lin

i did. the axis is right(I tried it for all of them anyways to make sure) and the range is set to a rediculously high number, so I know it has to be right…

:-? Well, if you still can’t get it workng you can post the .blend and we can see what’s wrong.

Jason Lin

Check and make sure you have face collision set on each object that needs to be detected by the ray :slight_smile:

figured out the problem(I think.) For some reason, the ray sensor is only working for me if the ray is pointing directly at the object’s center point. THe object itself is fairly large, so when it just points at the object it doesn’t activate, but when it’s pointing at the object’s center then it does. Dunno if that’s how it’s suppsoed to be, but that’s what happens. Using version 2.34, by the way…

Nope that’s not how it’s supposed to be. An object with a certain property can be detected by the ray even though the ray is not pointing to the object’s center point.

Something that I had been working on was a fish swimming around in a tank (Unreleased because it’s also part of a game that currently has some bugs to work out. Also need to model a better environment for the fish). Whenever the ray of a fish detected the wall, the fish would turn. This didn’t matter where the center of the tank wall was. Rays are supposed to detect the mesh not just the center point of the object.

Jason Lin

then I have no idea why it’s only working when it detects the centre. Oh well, I substituted it with a near sensor instead that causes it to orient itself towards the enemy, so I guess that will work too…

The ray sensor detects the physics proxy (polyheder, sphere, box etc) of an object.

Are you sure all the mesh’s faces that you want to be detected by the ray have collisions turned on?

positive. Oh well, I’ll go with what I have i guess…