Things randomly not working (especially logic bricks)???

Howdy.

So I’m making a game. In it there is an enemy which automatically faces the player when he/she comes within a certain distance. It also moves forward (towards the player) if it can establish a ray to the player within that same distance.

I also set up bricks to use a property “shoot” that starts at 100 and has an always sensor decrementing it by 1 - so I guess you might say “shoot” goes down by one with each passing unit of game time. I also set it to force an empty attached to the enemy to create a bullet when it reaches 0, as well as to reset the “shoot” property to 100 again to start the count over. The effect is that the enemy shoots once every couple seconds.

Now, if I attach ONLY the “shoot = 0” sensor to the “and” controller that tells the empty to create a bullet, it does what I just said - however it will shoot continuously regardless of whether the player is nearby. This is a problem because once I get 4 or 5 enemies in the level they’re all creating bullets simultaneously and needlessly causing things to chug. So I connected he ray sensor to the same AND controller - and nothing happens.

So I know that each of these sensors works individually. The ray sensor works because the enemy moves towards the player when it establishes the ray - I also know this isn’t just the near sensor I used to make it face the player, because I can get close to the enemy but from behind a translucent surface and the enemy will face the player but not move towards him/her. Like I said, I know the bullet property sensor works as well because it causes the enemy to shoot provided it is the only thing hooked up to the AND sensor.

So why is it that two sensors that each works on its own will cease to work through an and sensor? I had managed to get this setup to work fine in an earlier incarnation but blender crashed and I had to load an earlier version and do it over again - and it no longer worked. By the way, I set the ray sensor to TRUE level triggering - this did not help.

as a side note, it seems like this kind of stuff “just happens” in blender now and then. Something that clearly should work suddenly won’t, and you have to go back and load an earlier version of the .blend file, or simply accept the fact that blender won’t let you do something in the particular version of the particular .blend file you’re working on for no particular reason. Is it just me or have other people noticed this?

Bizarre… try using XAND.

Did I miss a version of Blender?
I can’t find an XAND. There’s an NAND - is that it?
I’m in 2.48a.

NAND just made it shoot constantly.

hmm… idk… I always use python…

Speaking of which, you know any good Python tutorials for the game engine? I have a basic knowledge of python itself but as for using it with blender I’m pretty clueless. All the blender python tutorials I"ve been able to find are geared towards doing things like generating objects and such and not anything very useful for game programming.

Maybe if I switch to python I can avoid crap like this.

These are tutorials I wrote: http://mediachicken.com/devforums/phpbb3/viewforum.php?f=37&sid=c74341e20562226291d9089c3c6f37ea

You should try http://tutorialsforblender3d.com

Also, your title is a little misleading, the truth of the matter is that you are inexperienced with the engine and you simply need some more experience as well as a little advice.

Yeah so take some time to study tutorialsforblender3d.com and remember that things such as whether an object or target are dynamic or not has a big effect on whether or not Rays and Radars are going to properly interact with one another.

Every game engine has its quirks like that. I’d even go so far as to say that blender game engine is THE MOST STABLE and workable game engine that I know of anyway.

So what you’re saying is that my objects being dynamic (or not being dynamic) affects whether an AND controller works?

I’d consider myself to be maybe intermediate in experience with the game engine. I’m pretty experienced with working with the logic bricks especially, and programming in general (though admittedly not programming for Blender python).

Not to discount you. The “things randomly not working” problem has seemed to diminish a little as I’ve become more experienced. :rolleyes: So I don’t mean to say you’re flat out wrong or anything. What I AM saying is that my ray sensor IS working, for certain, as is the property sensor. its only when I try to combine them through an AND controller that no positive pulses ever get through.

Both objects involved are dynamic by the way, if that helps. Though like I said, the ray sensor DOES already work, at least by itself, so I’m not sure if thats really relevant. . . maybe Im wrong.

See, the ray sensor IS working - on its own. I have the object set to move forward when the ray connects, and it does this.

I also have the property sensor that shoots every once in awhile. This works as well.

But if I pull out another “string” (or whatever you want to call those things that connect the logic bricks) from the ray sensor (which works on its own) and connect it to an AND controller - then pull another “string” from the property sensor, which also works on its own, to the same AND controller, it acts as though there is never, ever a positive pulse - though I can get close to the enemy and it will move towards me, indicating the ray sensor itself is working - and if I disconnect tha ray sensor from the AND controller, so that only the property sensor is hooked up, it will shoot. But like I said, it shoots constantly regardless of whethe the player is in front of the enemy or on the other end of the level, which is a problem.

It might be worth mentioning that I tested it - I disconnected the ray sensor from the ANd controller and replaced it with an always sensor. This worked fine, though obviously the enemy was still continuously shooting. Next I created a “test” property, set it to 5, then made a property sensor that would activate whenever “test” was set to 5. This also worked as expected.

finally, I tried making a property - “shooting” - and set it to “True” whenever the ray sensor was activated (and back to false whenever it was not). Then I made a property sensor to activate whenever “shooting” was true, hooked it up to its own controller, then hooked that up to the shoot actuator. This did not work! yet the Ray sensor still works on its own to move the enemy forward. I am so utterly confused! I’ve also tried every conceivable combination of setting different sensor’s true level triggering on and off. Nothing fixes it.

I think I’m going to use a lame workaround for now and just have the bullets cease to exist if they’re not within a certain distance the player. Let me know ify ou have any ideas what might be oging wrong here.

Scratch that - I just tried it and got strange, strange results. As far as I can tell the near sensor is checking to see if I’m near the same point in space at which the bullet object is located in the other frame/level/whatever you call it instead of where the newly created instance of the object is located.

By the way (again), I tried hooking my near sensor up to the and controller (instead of the ray sensor) and the SAME THING HAPPENED.

I’m gonna start breaking stuff.

help me. Please.

Sometimes I’ve had problems with properties and multiconnecting. I’ll tell you what, since you know little python use a tiny python script in form of an expression. Disconnect the property and change the ray’s and to expression, type this in: myproperty == myvalue
if you want it to be a string you need to use: ‘myvalue’ The expression controller can also handle things like: myproperty >= 1 and myproperty <= 10 and myotherprop == ‘true’

Post a blend file for us to look at, we can help you more then.

Multiple sensors connected to an and controller only registers a positive if both sensors send a yes signal at the same time. Some sensors, like rays and radars, only send a yes signal the first time that they see an object, so when the timer reaches 0, only one yes signal is sent.

A simple solution might be to activate pulse mode on your ray sensor, so that it will send ‘yes’ messages all of the time that it is true.

But that will create lag having a constant ray being shot =/ I guess you could use the near sensor.

I did that before I even had this problem. I just assumed it was necessary for the reasons you mentioned. This is why I’m so confused - I KNOW the ray sensor is constantly throwing positive pulses when I’m close to the enemy because it moves forward constantly as long as 1) I’m in range and 2) there is nothing between the enemy and me. I also know the property sensor works because it’ll successfully make the enemy shoot around once a second provided I don’t connect it to the ray sensor with the AND controller. So logically it seems that since ray sensor is throwing constant positive pulses as long as I’m in range, and the property sensor is sending positive pulses about once per second, that if I link them through an and controller that it should, as long as I’m in range, let a positive pulse through about once a second. It lets none through however.

Killer - I tried the near sensor as well. Same problem. Also disconnected the property sensor and changed the AND controller to an expression - “shoot == 0.” Same problem.

andrew - I just tried to attach the .blend to this post. Apparently its too big. Not too strange since this is a game I’m working on, and there are a lot of things I put into it and succeeded in getting to work before I ran into this problem. I could perhaps take a screen shot of the logic bricks if you think that might help?

I did it!

I’ll be honest, i’m not entirely sure why this was necessary, but it worked so I’ll take it.

Originally I had it set up so that the single and controller with both sensors hooked up to it would cause the enemy to shoot AS WELL AS reset the “shoot” property to 100 (I set it to shoot whenever shoot == 0). This time I set it so the AND controller with BOTH sensors hooked up did nothing but shoot the bullets, and created another controller that handled only the case where shoot == 0 in order to reset it.

Come to think of it, I can see now why this fixed it. Because when I wasn’t near the enemy, “shoot” would not reset at 0 so it would go negative then just continue to go lower and lower forever. thus even when I ended up near the enemy, shoot was already below 0 and going ever lower, so it would never HIT 0 and cause the enemy to shoot.

Kay_eva - Perhaps I owe an apology. You weren’t exactly right but close enough - this wasn’t a misunderstanding on my part of how blender works, but rather a simple logical error, which is actually probably more embarrassing. in other words, it wasn’t blender “randomly not working.” You got me there.

Thanks for all the help everyone.