I was wondering how one goes about making one object control another using logic bricks. For rexample, I’m wanting to have three buttons that control the rotation of an empty (That I will make parent to the model that i want to rotate). So if someone hovers over and right left clicks one of these objects, the parent will rotate instead of what is accepting the input from the user…
It is possible to connect the logic bricks from one object with the logic bricks at another.
I do not recommend that in your case.
Better use messages. That provides you a lot of benefits:
- the buttons do not need to know the parent
- you do not need to change your logic when you want other input options
- the buttons do not need to be in the same scene (e.g. overlay scene)
- you can have other buttons doing the same
- you can use keyboard keys or complete other input
- you do not even need buttons
How to do:
Think about what you would do to rotate the parent with keyboard. Apply this logic (keyboard sensor -> and -> motion actuator).
Now replace the keyboard sensors with message sensors. Each sensor should listen to messages with a specific subject (e.g.“rotateX+” or “rotateY-”)
Now you need objects that send such objects: your button objects. Each one gets:
mouse over + LMK sensor (True Pulse) -> AND -> Message actuator (e.g. Subject: “rotateZ-”)
Additional: add keyboard control via keyboard object(s) / this can be in one object.
keyboard sensor (True Pulse) -> AND -> Message actuator (e.g. Subject: “rotateZ-”)
I hope it helps
What you would do, is you would have your buttons, you would set up the left click and mouseover sensor for each of them, connect it to an and controller, but with a message actuator. You would then have a unique message for each of them, (eg rotate_x, rotate_y, rotate_z) and you would join them together. Then, selecting the empty, you would add three message sensors, and for each one they would have a different one of the messages that were sent by the buttons. You would then add three and controllers and three motion actuators which will rotate the empty.
That definitely did it guys! Thank you for the responses. I threw together an example .blend for anyone who runs across this thread to use as an example:
simpleOrbit.blend (305 KB)
for the sake of extending knowledge, to connect logic bricks between objects, just simply select the two objects(shift + RMB) and then you can wire to your hearts content. good answers above me though :yes:
EDIT:
I took a look at your .blend, and I think that if I were you I would change it to rotate on the global axis(un-mark the “L” on the motion actuators)
simpleOrbit.blend (457 KB)