Text game properties and dynamic text

I want to use the property value(it’s a string) of one object to change the text-game property value of another object(text-object).
For the time being I made the dynamic text to work by just assigning different values to the game-text property of the text object.
I have 2 questions, although the first one is not so important:

  • Do I need to tick “Text”, under Game Settings of the material of the text-object? The dynamic text works even if I don’t.

  • And the important question, can I achieve what I want with logic bricks alone?

    I can only access one object’s properties(the active’s ones, to be exact) when I select both. Any ideas or help on how to do this are appreciated.

This thread is also opened in http://blender.stackexchange.com/questions/40047/text-game-properties-and-dynamic-text

you will need a very small amount of python

Message ------python


import bge
cont = bge.logic.getCurrentController()
message = cont.actuators['Message']
own = cont.owner

if message.positive:
    own['Text']=message.bodies[0]

now any message that is directed to the text will set the text as the body of the message

So I use messages to move strings to different objects, but how exactly? If you have time can you make a screenshot or a blend file with an example?

The property Text, is what the text box displays,

so having a text Object with

Message(‘setText’)------python

and

in another object

if keypress X ------and-----send message subject: setText, body = ‘Test text two’

so this will set the Text property in your dynamic text object
toTest text two

you can also send a property as a message

you can also do

always-------and-----copy property text from target property text

(copy the text each frame from a game object)

Attachments

DynamicText.blend (465 KB)

1 Like

Great, i can work with this. Only problem was that when you did the thing with the prop property and gave it a value, it doesn’t work in my case. It spawns the name of the property instead. But that might have to do with the fact that in the start my property has no value or a " " one right?

do property instead of body

in the message actuator

Attachments

DynamicText2.blend (465 KB)

Many many thanks!

The BGE Guide to Messages incl. Healthbar tutorial will help you :D.

1 Like