okay so here is my thing, i have ben coding an inventory where every item inside of it got an prop called “name” inside that prop i put the display name of every item.
now i need to get the value from that prop to display on an other Text objekt when the mouse is hovering over it.
any ide on how to do this?
my ide where to make an sensor on the mouse check if the objekt got [“name”] prop and if it got it pass its value to the [“Text”] prop on my display objekt, but i cant find a way to use the sensors in that way.
i use a MASTER object, that recognises the hitObject and it Properties, Values or attributes.
This master object has a property sensor, wich saves the id(KX_Game_Object) function.
Like this the master can recognise, if the hitObject has changed.
If so, call a function that reads the hit Object and then send a message called ‘update’ for example.
The Text-Object itself has a Message sensor. Always if the message comes itno the TextoObject, it reacts and gets the values from the master hitObject.
Sometime it is necessary to store the hitObject somewhere…
that wold maby work, but i don’t rly think it is the solotion i’m locking for bco i use that many item’s, i dont wan’t to implemant new feautures on over 100 objekts, i need to use only the existing values and only make changes on the mouse objekt
do any one have a way to get the objekt an Radar sensor is reakting on?
if anyone got an way to do this, then i think i might have the solotion
A Mouse Object? In Terms of Blender (»Object«) there is no Mouse Object. But you could create one that always follows the Mouse Curor and if that Object touches an Item it may read the Items Name Property and send it as a Message.
However, I am afraid to tell you that you have probably done something unhandy: You should not make 100 Items when your System does not yet work and they all have their own Logic, you should rather keep it small, using only three Items or so, and then, when it works finde, then you can increase the Amount of Items.
However, on the other Hand your Approach is to keep the Amount of Logic for each Item as low as possible, and that is, without a Doubt, a good Thing! So probably you’re doing something handy, after all! ^^
EDIT:
Ô, and if you are using LogicBricks: You should use Python. One simply cannot organize a whole Inventory with mere Logic Bricks. The Python Scripts have the Advantage of being easier to adapt to several Objects. One Script takes two Bricks, but it can include more than Hundreds of »Bricks« in itself.
the whole inventory is alredy working, this is only to make it lock a bit nicer, and the inventory is made in python;), whit the “mouse” i do ofc mean an plane that is folowing the mouse position and therfor lock’s like an “mouse” when the game engine is runing.
do you guys have a way to get an radar sensor to get the name of the objekt it aiming at into a python code?
No Radar Sensor, I don’t see why a Radar Sensor would be of any Use here.
The Plane, the Mouse Object, shall identify the Object it touches: MouseOverAny Sensor > Python Script:
from bge import logic as g
cnt=g.getCurrentController()
<b>mouseoverany</b>=cnt.sensors["<b>MouseOverAny</b>"]
print(<b>mouseoverany</b>.hitObject.name)
EDIT: Tested, this should work! (However, if you already have that Mouse Plane, it might interfere.)
Be aware that I have rewritten the Concept a Bit since I posted it the first Time!
okay!, i solved my problem whit an Ray sensor and a python script
in this way my objekt’s DON’T need to collide to get and past an prop
here is my script:
import bge
cont = bge.logic.getCurrentController()
scene = bge.logic.getCurrentScene()
sens = cont.sensors["touch"]
txt = scene.objects["txt"]
x = sens.hitObject
myObID=id(x)
if x == None:
print(x)
else:
ob= scene.objects.from_id(myObID)
if ob["end"] == 0:
txt["Text"] = ob["name"]
in this code i use the fact that all of my inventory objekt’s got the key “end == 0” by default. what my cript does is to get the key “name” from any objekt stroken by the ray and passing it to the “Text” key on the objekt named txt.