where are you trying to do this? in a program or the editor?
for a lua program, this gives me the position of a pick for any entity class including terrain:
pick=CameraPick(camera,Vec3(GraphicsWidth()/2,GraphicsHeight()/2,1000.0),0,0)
if pick~=nil then
pick_posX=pick.position.x
pick_posY=pick.position.y
pick_posZ=pick.position.z
end
it should also work for bmax as well
hmmm... weird. if i take out the skybox it seems to load the firepit without the error, but the fire and heathaze are missing and the fire sound only plays one loop. If I have a skybox then I get the error.
ok... must have been an issue with my update... I performed a clean install and the firepit loads with the skybox now. I still do not have heathaze or fire, but I assume I will have to edit the firepit.lua to perform a GetGlobalObject for the transparency world...
hey i got something right! yay!
just doing some initial testing with the single state lua with bmax... and came across some other things...
with the firepit in a scene loaded from bmax, i now get a 'Unhandled exception:GL_INVALID_VALUE'
with the locker in a scene loaded from bmax, i see in the log:
and its about 50/50 whether or not the door is there... and if it is there and my controller touches the door, it goes flying across the map... what do i need to do to get the 'joint' to be recognized?
ok... i noticed that the error occurred not when I placed the waterplane object in the scene, but if I tried to move it afterwards...
then i noticed that if i moved the position by the properties selection, no error occurred.
So replace this line in the function object:UpdateMatrix():
self:Update()
with this:
self:Refresh()
and it seems to have resolved the issue...
ok... thought it might have something to do with it since it was failing at self.Update()... and i assumed i would have to uncomment the Update
so whats the fix to the error then?
where does this go? in the class.lua? just wondering because I get an error whenever I put a waterplane into the editor... fails at this line:
self:Update()
inside the function object:UpdateMatrix()... the error is 'attempt to call method Update (a nil value)'
it looks like its SetLayerScale in bmx and SetTerrainTextureScale in lua if I had to guess... and it looks like SetLayerScale may be removed shortly if what the wiki says is true... but currently bmax in 2.3 still recognizes it.
ok... of course the above code wouldn't return anything for position if the entity class wasn't equal to a terrain... if all you are wanting is a position for your pick no matter what the entity class is:
pick=CameraPick(camera,Vec3(GraphicsWidth()/2,GraphicsHeight()/2,1000.0),0,0)
if pick~=nil then
pick_posX=pick.position.x
pick_posY=pick.position.y
pick_posZ=pick.position.z
end
why does the math have to be an entity? why not just a script thats loaded with an actual entity?
and if the filter function parameter exists in lua, then this would take care of your issue...
true... but typically lights won't be just sitting in the middle of your map without something else around it... if you had something pickable next to it, you would probably wouldn't even notice in game... as for the other 'logical entities', just make the invisible model for it smaller if its getting in the way... there are a several ways to get around this issue that don't require anything to be changed from the way it is currently. All of which just means you have to use common sense when laying out your scene if you expect a certain interaction.
and... there's always the filter function parameter... assuming that it does exist in lua, perhaps Josh or someone could give an example in lua...
you have to do what is listed in this post.
also you will need to send josh an email to let him know when you purchased the upgrade with relevent info like your name, LE 2.0 registration key, your forum name, the email that you are using in the forum if different than the one you are sending that email from... etc...
you can just filter out the lights by either checking for the classname or by the model's entitytype by using GetEntityType... since all lights have an entity collision type of 0. you would just have to make sure everything else that you want to be pickable have a different value than the lights...
if pick~=nil then
if GetEntityType(pick.entity)~=0 then
DoSomething()...
end
end
anything else you are wanting to have collision with but don't want it pickable, you just need to filter that out as well... there's no reason why everything in a scene shouldn't be pickable if needed to be... its up to the programmer to decide how the resulting interaction should be handled not something that should be built into the editor or the engine
funny that in your post LinePick, you state "I need it to collide with anything and everything" with regards to picking... but since it actually does, you complain that it shouldn't?
the terrain is a pickable entity, you just have to filter the results of the pick correctly because not everything you can do to or evaluate with a picked model/mesh can work on a terrain...
if pick~=nil then
if pick.entity:GetClass()==ENTITY_TERRAIN then
terrain_posX=pick.position.x
else
name = GetEntityKey(GetMeshModel(pick.entity),"name")
end
end
look at the scripts/constants/engine_const.lua for entity class values
huh?? the script editor has intellisense? how is that feature enabled?
as for your crash... i haven't had any crashes yet that weren't my fault because my code was either really messed up and tried to run it or i tried to run multiple scripts at the same time without exiting the first one... so more than likely you did something and didn't realize it.
need more code than that to troubleshoot... where are you setting entity.hidden to a 1 after you turn off the light? that if-statement is looking for entity.hidden==1 to turn on the light...
for the player, you are setting the position of the pivot first then the cube position based on the pivot.
for the camera, you are setting the position of the cube to the pivot, then setting the camera to the pivot... so how is this making the cube follow the camera?
shouldn't you set (better yet parent it) the pivot to the camera's position, and then set the blue cube to the pivot position...
its hard to tell with out actually seeing this in action and just guessing on how your camera is being controlled...
do we have a decent way of locking down our assets yet? because you know better than anyone here, the moment that gmf2-whatever converter gets released it will be all over the internet... just making it even easier for people to steal models. what are you using for the private folder models?
look at how the lights are done:
function Kill(model)
local entity=entitytable[model]
if entity~=nil then
if entity.light~=nil then
entity.light:Free()
entity.light=nil
end
end
base_Kill(model)
end
you should take a look at the firepit example model that comes with the Editor... has heat haze and fire built in via lua script... makes all of these things basically a part of a object now that gets created when loaded...