Argoon wrote:Hello guys i was able to fake a mouse over script here, i change the cursor image by a hand image when i mouse over a object, i use the rayhit function to detect the object and i just activate or deactivate a fake cursor (a plane with a image with emission on and a follow plus lookAt behavior, that is right in front of the camera) when the ray detects the object i want the cursor changes, works fantastically.
But now i have a question, from my inexperienced point of view, every time i want to make a object "mouse over" enabled, i need to make individual functions to all new objects (with repeated code), imo if true this would be unmanageable with so many different interactive objects on a scene, (and the script would be very confusing and big), but if i add a way to Tag a object then this would not be a major problem, does it? Because i think only one function would work for all objects with different names but tagged for example "interactive".
for example a getTag() function would be nice but has it doesn't exist, at least i don't see it anywhere, what can you guys suggest that i do? Do i really need to make a bunch of functions for every object on my level that i want interactive or there's a more easy way?
What you really want is a CLASS. This is part of the reason I made my post on how to make classes in lua. Anael also responded with a link to the wiki.
Also, have you seen the:
getProjectedPoint(object, point)
function?
I think that has something to do with the mouse also.
On Classes:
Classes are just what they sound like. An apple belongs to the class of FRUIT, and so does an orange. A man belongs to the class of HUMANS, and so does a woman.
Fruit also have various properties, like TASTE and COLOR and TYPE. These would be variables in the class. And humans have various properties also, like a NAME and an AGE and a RACE. Humans also have ABILITIES. Humans can WALK, and TALK, and JUMP, etc. These would be functions in the class (Also called METHODS).
So if I were to create a new variable named manzana, and I made it part of the fruit class, I could just give it properties and abilities without having to type out the function over and over for a new fruit.
When you make variables that have these abilities and properties they are called OBJECTS.
Example:
--We make joe a person
joe = newPerson()
--now we can do stuff with joe
joe:Walk()
joe:Speak()
joe:Dance()
print (joe.name)
print (joe.age)
print (joe.height)
--create another person
sara= newPerson()
sara:Speak()
sara:Dance()
sara:Walk()
print (sara.height)
print (sara.age)
print (sara.name)
And we could keep doing this over and over and over.
Last edited by Tutorial Doctor (2013-08-27 01:40:33)