Determining if saucer is in my sights PureBasic

Started by Pfaber11, November 23, 2019, 17:07:26

Previous topic - Next topic

Pfaber11

Been working on something new I have my 3d terrain working nicely and have populated it with flying saucers . I Have my camera moving around the place and have attached it to a sphere for registering if  I get hit by enemy fire . The problem I have is when I have the saucers in my sights I need it to Know it so a light will turn on . The sights are 2d and the saucers are in the 3d world . Tried using the point command without any success . Thoughts on this anyone . Thanks for reading .
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz

Pfaber11

#1
Been playing around with point and although it isn't going to help in this situation it may prove useful in the future . So how do I get the computer to respond when my sight is trained on the enemy . Hmm thinking cap on.
  Edit : No idea.  ???
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz

Pakz

Can you not use a getangle function?

Also firing a series of invisible weapons Per loop to see if it hits anything always helped me before.

Coder Apprentice

#3

CheckObjectVisibility(#Camera, ObjectID)       - It checks if an object is visible for the specified camera.

PureBasic help file \ Engine3D \ CheckObjectVisibility

Pfaber11

Thanks for the info guys gonna try your suggestions .
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz

Pfaber11

Hey Kris got this working
If CheckObjectVisibility(0,EntityID(50)) > 0

works well .not sure how it's gonna help me yet although it will help in checking for a missile strike as in knowing which entitys are on screen so it knows which one to check.
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz

Derron

Quote from: Pfaber11 on November 24, 2019, 10:33:35
If CheckObjectVisibility(0,EntityID(50)) > 0

works well .not sure how it's gonna help me yet although it will help in checking for a missile strike as in knowing which entitys are on screen so it knows which one to check.

(sorry for the almost full quote - but there is not much to cut ...).

Ahemmm ... I am excited to see games in which missiles only strike you if you see them! Must be a world without backstabbing.


Missile hit / whatever hit:
- object coordinates + a hull/bounding box
- player coordinates + hull/bb
- check if boxes collide - and then if hull (more exact)

Think we had this described in another thread already. Learn from it.

bye
Ron

Coder Apprentice

Quote from: Pfaber11 on November 24, 2019, 10:33:35
works well .not sure how it's gonna help me yet although it will help in checking for a missile strike as in knowing which entitys are on screen so it knows which one to check.

I probably misunderstood you. I thought you want to detect if a saucer is in your "sight" so you can setup a warning light.

Pfaber11

#8
Yes Kris that was the idea and I have used checkobjectvisability (entityID) and after a long time got it working very well and it's pretty accurate.
Edit: I spent about 8 hours getting it all working properly and I did it by creating a very small camera like camera 1x1 as small as it can get and put this right in the middle of my sights and pointing straight ahead . When the entity is in the sights it tells me which is what I wanted . Then you press fire and bobs your uncle exploding saucer (yet to be done ) . Still getting 60 fps with all this going on . Got 46 saucers and one other entity.
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz

Matty

#9
A  dot product between the forwards normalised vector for the camera and the normalised vector from camera to object will give a value greater than zero if it is in the front 180 degrees and grearer than 0.7 if it is in the front 90 degree arc...should help.

Pfaber11

Yes got that Ron will need it sooner or later thankyou. Gotta sort out some explosions next . I am thinking the saucers will glow red then explode sorta like war of the worlds style . Gotta have some levels of difficulty as well and saucers fighting back . Long way to go but wanna get it complete before Christmas . Gives me a few weeks to get it done . Anyway that checkobjectvisability() is excellent and it doesn't slow the whole thing down . Moved the camera view off the screen so it can't be seen still works the same . made it's viewing POV to 1 so it's only displaying and reacting to the very center of the screen where the center of my sights are . Never would of considered this before but it gets the job done . I also made the width and height of the camera (1,1) not sure if that makes any difference . I think it is explosion time and am expecting this to take a few days . Never animated an explosion before so this is fresh ground for me . Any advice would be welcome on how to do this .
Have a nice evening .
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz