Game Development Community

Getting variables (with the engine)

by Trevor "PointDestruction" · in Technical Issues · 08/26/2002 (4:10 pm) · 4 replies

Erm, ok, i've never really understood this: heres an example: I want the code in the engine to search for objects in view (code already in place), and then when it finds an object, it does this:

if (ShapeBase* obj = dynamic_cast(info.object))
if (obj->getShapeName()) {
yaddah


Now, in the actual game, everything has a number that identifies them as an object in the game, which is always random. How can you get that number and then call a script with the engine?

#1
08/26/2002 (5:47 pm)
Erm ... figured that out, heres another question :/


Ok, heres what i'm trying to do, in the onRender function for the crosshairs, I want to add a check for items as well, which i've successfully done. However, I want to have it call a script for every tick, which will display a bottomprint with info on what your looking at.



However, I cannt figure out how to get the player or the client of the controlling crosshair ... this is what I'm using to call the script:

Con::executef(dynamic_cast(obj), 3, "ItemDetails", conn->getControlObject());


however, whenever I look at the item, it freezes up the game now .... help will be MUCH appreciated
#2
08/26/2002 (6:06 pm)
I'm not an expert on this, but could you cast a ray from the player's eye point? When the ray collides with another player, I'm sure you could get access to the information you need.
#3
08/26/2002 (6:26 pm)
erm what?? Thats not the answer I was looking for :/
#4
08/26/2002 (6:48 pm)
Quote:"However, I want to have it call a script for every tick, which will display a bottomprint with info on what your looking at."

I think it is the answer you want. You cast a ray from your eye point. The ray collides with an object, and the engine returns the object that ray collided with, and you now have the object that you're looking at.

Ergo, quad erat demonstrandum. Or something like that.