Is there some equivalent of font.move_select() from bpy that can be used during game runtime?

I'm building a karaoke GUI and I need a way to add a different color/material to the syllable that is currently being played.

I know this could be done having two separate layers of text with different materials each, but I'm looking for a way to addapt an existing code I have built on python's Pillow module.


2 Answers 2


In BGE or UPBGE 0.2x, there isn't really a BGE equivalent of that BPY function.
UPBGE 0.3x on the other hand, allows BPY to fully works at runtime, allowing you to use font.move_select() in real-time.

You can only assign different materials to individual text characters if you use either the [BGE] BLF module (dynamic) or the you convert your text object to a [static] mesh, but the latter disables dynamic changing of its text.

  • $\begingroup$ I was a bit confused about the use of BPY in general with UPBGE, that explanation just helps a lot. So Can I combine BPY to select the text and then assign the material with BGE? $\endgroup$ Jun 8, 2022 at 17:31
  • $\begingroup$ I finally found that I was able to use BPY only for this purpose. Posting an answer with an example code. Thanks for the guidance! $\endgroup$ Jun 9, 2022 at 11:37

I managed to get a working version during game engine runtime, on UPBGE 0.3 using only BPY.

Thanks to @Rpaladin for the helpful information to start with.

Here's the code:

import bpy

context = bpy.context
#testtext is a text object with that name. Text cursor should be at the begining of the text before you run this code (in edit mode)
context.view_layer.objects.active = context.scene.objects.get("testtext")
#enter edit mode
#The text object has 2 materials, material 0 (first one) is set by default to all text
context.object.active_material_index = 1
#go back to object mode

You must log in to answer this question.

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