Make text appear?

How can i have Text appear using The mouse over sensor, Example if you have an object lets say its an Apple. How would you make the text “Press “E” to pick up” Appear while the mouse is over the object then have the text disappear when the mouse is off of the object.

I would be open to use any other methods you have other than using any python, as this project is to be built only using logic bricks. Thanks ~Nero

Here you go.

Attachments

hover text.blend (492 KB)

Thanks thats exactly what i wanted, though im not sure what you did… can you break it into steps?

I have to apologize I had not looked at the blend provided, but a simple trick to do is to change the text to an empty string if it is not hit by the mouse cursor. Otherwise if the mouse hits it set the text to what you want it to say.

typewriter text is fun.

you can do


#if you have text not shown and a random value is greater than .9
if len(own['unseen'])>0 and bge.logic.getRandomFloat()>.9:
    #add 1 character to visible string from unseen
    own['Text']+= own['unseen'][0]
    #remove first character from unseen string
    own['unseen']=own['unseen'][1:]

UUmmmm… I’ll try. Sorry, but I’m just learning this stuff as well, so I’ll do my best. Here we go!

  1. Make your text and whatever “bubble” you want it to appear in. Two routes here – design this as a single object which would allow you to not have to do a lot of the double stuff below, or design it as two objects (like the example) which will allow you to have one “bubble” design for the entirety of your game, and allow you to only have to alter the text. Pros and cons to both, as with life.

  2. Create a “game property” for both your text and your bubble. This has to be done with each individual item, however I’m sure there is a way to copy/paste object properties*. Name it whatever you want, but in that .blend I attached it was “vis” short for “visibility”. Select the “Boolean” option. Boolean means the value is either True or False, like a push button switch. The check box has something to do with whether or not the initial state is True (walk into room with light on) or False (walk into room with light off), though I’m not exactly sure as I’m still very new at BGE.

  3. Back to your target object (Your example = an apple). You wanted the text to appear when mouseOver. So - make two mouse sensors and change the mouse event (default “Left Button”) to “Mouse Over” from the drop down menu. Select the “Invert” button on one of the two (I always do inverts on the second sensor, but your choice). At this point what is happening is Apple is waiting for the mouse to be over it, and the mouse to be not over it.

  4. Still at Apple. You have your two sensors, so now you want something to happen when they are active (mouseOver or mouseOver – invert (which equals mouse not over)). I used the message actuator. All the message actuator does is send out a message to a specific object (whisper to friend), or if you do not address it to a specific object then it just blasts a message out through the whole game, across all scenes (loudspeaker) which can be useful in some scenarios. Since the bubble and text are set up as two separate objects, I needed two messages, one to each object. What you label the logic brick as does not matter, but keeping it simple and obvious is helpful, though not required. I used “vis” once again because if I were to add ten more bricks and condense them, I’d have an idea of which is which at a glance. The subject of the message is what the receiving object will be looking for. I really should not have made everything “vis” in this, sorry about that.

  5. Still at Apple. Connect your sensors to your actuators via an “And” controller. “And” controller means that all things going to it must happen (at the same time) to make the actuator actuate. Then connect your “And” controller to both message actuators, because you want to send a message to both your text and your bubble. So at this point, your Apple is looking for when the mouse is over it, and for when the mouse is not over it. When the mouse is over it, the apple will send a message to both your text and bubble. When the mouse is not over Apple, it will also send a message to both your text and bubble.

  6. Okay, this part is going to be the same on both your text and bubble. The nice part is that you can just do it on one of them, and then copy all the logic bricks over**. First, you want a message sensor. This will search for any message with the subject you enter, regardless of source. Your actuator is going to be a “property” actuator. The property you will be dealing with is the boolean you made earlier, titled (like everything else with my poor decision making) “vis”. Also, you want to change the property “mode” to “toggle”. This is going back to the push button switch – a value of 5, 12, 102452 doesn’t make sense with a boolean (push button), it is either on or off. Toggle mode means that it will just bounce back and forth every time that the sensor is received***. Change the property to the only one that you have made for that object (you can make as many properties as you want for each object). At this point, this object is now searching for a message with a subject (that should be the same subject as what Apple is sending), and when it receives that message, it is going to toggle the boolean property. However at this point the boolean property is not doing anything, regardless of how many times it is toggled.

  7. Still at text/bubble. Now we are going to set what actually happens when the boolean property is toggled. Add in two property sensors. Evaluation type “Equal”, property “vis”. On one, enter “True” for value, on the other enter “False”. This is (once again) because boolean is on or off, no in between. Next up, add two visibility actuators. On one, check the box “visible” and on the other, do not check that box. Connect the “True” property sensor to the “visible” actuator, and connect the “False” property sensor to the not visible actuator.****

Uuummm, that should be it. I’m confident that some other people here can find a few better ways to explain what is happening, (once again, I’m pretty new with this stuff) but that should do it. Sorry I didn’t write that up earlier, it was late and I was getting ready for bed. Also sorry if this explanation is overkill, but I get frustrated when people assume I have any concept of what is going on, so skip the parts you all ready know. Maybe that will help someone else learn something. I don’t know. Let me know if you have any other questions and I’ll try to remember to check back in and look for a response!

*After a lot of struggling, I finally realized that object properties aren’t always things like color, shape, etc. Properties really can be things that you just make up. I’ll see if I can find a reference for you to better explain if you don’t all ready have an idea. Copying can be done in the same place as copying logic bricks.

**Copy logic bricks: Select all objects you want to paste logic bricks to, and select the object that has the logic bricks you want last. At the bottom of the 3D view port, go to Objects>Game>Copy logic bricks.

***Experiment – using the .blend I sent, remove the mouseOver – invert sensor on the target (apple). Now the hover over text and bubble will disappear and re-appear, but only when the mouse is moved over Apple.

****Experiment #2 – swap the visible and not visible actuator connections to the property sensors. Now the hover over text will only be visible when the mouse is not over Apple.