2
$\begingroup$

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.

Also posted on : blenderartists

$\endgroup$

1 Answer 1

1
$\begingroup$

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.

This is not necessary on Text Objects (KX_FontObject). This configuration is for Bitmap Text materials (different topic)

I achieve what I want with logic bricks alone? Yes, it is possible, but only with hard-coded relationships and within the same scene.

Usually I recommend to use Python to get this behavior as this allows to decouple the "value keeper" and the "value viewer".

So here is a Logic brick brick solution.

As the property acts as our model (game's state) we call it in our example "model". We call the object it lives on "Model.keeper". [You can call it as you want].

A model makes not much sense when it never changes. Therefore we implement a sample change operation - we add the string " value" whenever we press .

enter image description here

Model.keeper

Now we want to let another object take over the property value. Add a Text Object with Text Game Property "Text". Call the object "Model.viewer". We can use the Property Actuator in "Copy" mode to tell it to copy the value from object "Model.keeper" with property "model". The GUI supports us when typing/selecting the fields.

enter image description here

If the Model.viewer constantly copies over this value, your game will become busy with copy operations (imagine you have much more than a single viewer). Wouldn't it be more efficient when this will be done on model value change only?

The Property Sensor in "Changed" mode senses when the property value changed. Optional: The object "Model.keeper" knows when the model changed (because it changed it). So it can notify any interested object (e.g. "Model.viewer") that the value changed. We can do that with a message:

enter image description here

[I placed this logic into a separate state, too avoid mixing different tasks. Both states are active.]

I suggest to enable "True Level Triggering". This way the message gets send on consecutive changes too. The subject of the message is "model changed". This allows us to send other kind of notification messages regarding other events. Please not this is send to any object (empty To: field).

Model.viewer

When "Model.viewer" receives the message "model changed". It will activate the Property Actuator as you already setup above. This means whenever "Model.keeper" notified "Model.viewer" via "model changed" the property "model" gets copied to property "Text".

But what if we just started? The value did not change an therefore there is no notification message. To cover this situation we activate the Property Actuator at start-up too. Be sure to use an "OR" controller:

enter image description here

If you did everything right you should see something like that:

enter image description here

Homework Add another viewer

$\endgroup$
1
  • $\begingroup$ I went with something similar to this but I did this by "If the Model.viewer constantly copies over this value, your game will become busy with copy operations (imagine you have much more than a single viewer)." . I'll change it if it slows down. That "copy" in the properties is so usefull!! Many thanks! $\endgroup$
    – Lev
    Oct 15, 2015 at 18:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .