Is it possible to draw an outline around an object when the mouse is over it like in the blender viewport when you’ve selected an object? I want to highlight objects that the player can interact with by that, so only objects with a certain property should be highlighted.
Easiest way would be to duplicate object and flip its normals, give new material to this duplicate and set it to shadeless. Other that that would be through custom shader i guess.
So I would have to duplicate every object? Or is there a way to duplicate and flip normals via python, so that I can delete the duplicate if the mouse isn’t over anymore?
import bge
bge.render.showMouse(True)
cont = bge.logic.getCurrentController()
own = cont.owner
sce = bge.logic.getCurrentScene()
mouse_sensor = cont.sensors['mouse_over']
hit_ob = mouse_sensor.hitObject
if hit_ob and hit_ob == own and own['spawned_ob'] == False:
new = sce.addObject('objects_name',own)
own['spawned_ob'] = new
elif not hit_ob and own['spawned_ob'] != False or \
hit_ob and hit_ob.name != 'objects_name' and hit_ob.name != 'Suzanne' and own['spawned_ob'] != False:
own['spawned_ob'].endObject()
own['spawned_ob'] = False
Though a better way would be to run script on single object and deal with all objects than running separate scripts on each object
No, you duplicate meshes. No, You duplicate meshes that should get an outline. (Alternative you can search for toon shader, or outline).
Yes, just write one.
Btw. scaling alone is fine at a sphere or a cube. You do not need scale, you need “fatten” = thicker objects. There might be a tool for that.
Yes, when it is a separate object.
(if you use a shader, deactivate/remove the shader)
Alternatively you can add (parent) the outline mesh to your player/enemy/object or whatever it is and set it to invisible. Then make it visible when mouseover. When it’s invisible it won’t affect your performance at all.
A benefit of this is that you can make the outline mesh animated along the regular mesh via an armature.
At the moment, only by using separate scenes, and duplicating the state of the main object to the state of a proxy object. This would not be performance friendly.