Touch: I don't get it

I’m wanting to make a simple breakout game to start learning the BGE.

I can easily make my bat move with arrow keys, but I can’t seem to make it stop when it reaches the edge of the play area. File attached.

I have used an “OR” link to try and make the bat bounce (go the other way) when it hits a barrier. It seems to be blind though, and just goes through it.

What am I missing?

Attachments

game_breakout01.blend (41.8 KB)

Hey,
you can use a constraint actuator. Set it to location, loc x, min: -6.3, max: 6.3. Connect it to an always sensor.

See how that goes for you.

And you can turn off pulse mode on the always sensor. Constraints just have to be defined once and then they are there.

I can see one called “actutator” but there seem to be no options to set this up as a contraint. I learlier tried a standard constraint restriction (not the BGE actuator one) and it made no difference to in game movement.

I’m also confused as to why my touch is wrong. I’m thinking I’m going to need it to work for when the ball hits the bat and (later) bricks.

I found this: http://www.tutorialsforblender3d.com/GameDoc/LogicBricks/Actuator_2.html but I don’t have “constraint” on my sensors list, and “actuator” doesn’t show anything to do with Location.

The touch and collision sensors require at least on of the objects to be dynamic. Also, the “Constraint” isn’t a sensor, it’s an actuator, like motion. Do what andrew-101 said, and use the constraint actuator, it works fine:

Always (no pulse) -> AND -> Constraint (location, locx, min: -6.3, max:6.3)

‘Constraint’ is an actuator, not a sensor.
I could follow andrew and Sim88’s replies easily, you just have to read carefully.
Good luck with your game!
[Edit] aw, Moguri (i thought i had refreshed that page) :slight_smile: (nice avatar)

I never knew that, thanks.

I noticed that when I wanted to turn them off, and couldn’t.

Okay then… I’ve had another go through everyone’s responses and the penny’s dropped in terms of me understanding what’s being said. I’d been focusing too much on the sensor end.

Lack of the “dynamic” property is what had been originally stopping my previous method of bounds from working (thanks Moguri), though the constraint actuator is a more straight forward method in terms of not needing collision to work and likley lower CPU demand (thanks pretty much everyone).

Attached is the improved version, with my next question (I’m trying to learn the basics here).

New question:
I’ve added the ball now. What would be needed to make that ball have a starting direction and bounce around in a frictionless (no slowing down) manner? I’ve added some “properties” (variables?) for directionY, directionX and speed which I think might be used.

Also, I’ve locked the Z axis of the ball. If it’s not even moving, why does the ball appear to bounce at about 4 seconds into play and what can be done about it?

,

Attachments

game_breakout03.blend (43.5 KB)