Problems Picking types

Blitz3D Forums/Blitz3D Programming/Problems Picking types

cash(Posted 2006) [#1]
I am going in circles. I have code that works but cannot figure out what the difference is to what I am currently working on...

I use a for next loop to create my enemies with a copyentity.
This works and each pass of the loop positions the entity then assigns scale and entitypickmode to 2.

Trouble is only the last enemy created is actually pickable.
This is regardless of whether there are 1 or 200 enemies.
Only the last one created is pickable.

I use types to assign the parameters and I have copied this from a working program I have. Any ideas ?

Note: All other pickable items are working fine and enemies work if I create each one individually with loadanimmesh and assign all variable individually. Not ideal though.


BTW: If you are creating a FPS game, buy the CSP Engine 7 its awesome.


jfk EO-11110(Posted 2006) [#2]
thanks.

I really never heared of this picking problem. But if I was you I'd isolate the problem as much as possible.

Create a cube, use copyentity a dozen times or so and check if they can be picked. No types and things, a very simple, short code.

If it turns out picking works then it may be a bug in your code, often a typo or so.

You may also try to set the pickmode on the first mesh, then copyentity it and see it the pickmode was copied too.


(tu) sinu(Posted 2006) [#3]
could you post some source, might be a simple coding error.


cash(Posted 2006) [#4]
okay I have it working now but heres what was going on

function picks()

pick3=camerapick (camera1,400,300)
for e.enemy=each enemy
if pick3=e\enemy then
txx=1
else
txx=0
endif
next
end function


The above did NOT work




function picks()

pick3=camerapick (camera1,400,300)

for e.enemy=each enemy
if pick3=e\enemy then txx=1
next

end function

Nor did the code above

However this did



function picks()

pick3=camerapick (camera1,400,300)

for e.enemy=each enemy
if pick3=e\enemy then txx=1
if pick3=man then txx=2
if pick3=level then txx=3
next

end function


strange.


b32(Posted 2006) [#5]
In the first code, you state in a loop:
if pick3=e\enemy then txx=1 else txx=0
If the first e\enemy is picked, txx will be one, but after that, in the second loop, txx will be set back to zero.
Using "Exit" to exit the loop will keep "txx" one.

In the second code, I can't really tell what would be wrong. Maybe it is that "txx" is never reset to zero, so once it is one, it will never become zero again. Try using "txx = 0" before the loop ?

If you want to extend the use of the function Picks(), you could use the "Return" command. Instead of using txx in the function (did you made txx global ?), you could also use:
if pick3=e\enemy then return 1
if pick3=man then return 2
next

return 0

And then call the Picks() function like this:
txx = Picks()