Simple question.
How can I get a ray cast sensor to read product ID from an object it detects?
I will admit I’m not the best at python programing but I’ve been trying to make this work for a day with not much to show for it. If anyone has a solution or could point me in the right direction it would be highly appreciated
Cheers, Maffi.
Add a component signal on your raycast sensor.
then look up for that signal in script
Signal1=comp.findBehaviour(“CompSignal1”)
then read the signal value which is component and then from component properties read that ID or what ever you need.
1 Like
def OnSignal( signal ):
if signal ==Signal1 and signal.Value!=None:
part =signal.Value
ID=part.getProperty("ID")
1 Like
You are a legend! Thank you!
Im gona try my hands on this asap!
More info:
1 Like
Thanks @Unnahi for the help! I got it to work.
I managed to print out product ID after it passes the sensor , now i will be able to use it for further logic. Just a small note for anyone in the future , to use the product ID you need to add .Value to the variable it stored at.
Code I used for anyone’s convenience
from vcScript import *
comp = getComponent()
Signal1 = comp.findBehaviour("CompSignal1")
def OnSignal( signal ):
if signal == Signal1 and signal.Value!=None:
part = signal.Value
idProp = part.getProperty('ID')
print idProp.Value
2 Likes