Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Get3DVectorXFromScreen help and ObjectRayast

Author
Message
Gibbon28
12
Years of Service
User Offline
Joined: 22nd Oct 2012
Location: Derbyshire, UK
Posted: 4th Jan 2013 10:18 Edited at: 4th Jan 2013 10:19
Hi, im trying to understand how to use these but they dont really make sense, or work like i expected them to.

Get3DVectorXFromScreen
Quote: "Converts a 2D point on the screen into a vector pointing into the 3D world. The vector is normalised to 1 unit long, to extend it into the world simply multiply it by your desired distance."


Ok, so this becomes normalised so does that mean i need to multiply the x & y by the window size to get this to work, or does this actuall use the normalised X & Y coords?

ObjectRayCast
Quote: "Casts a ray through 1 or all objects to check for intersection with the object. Rays are define with a start position and an end position and does not collide with backfaces, will return the number of the object hitt first, or 0 for no collision. Ray casting commands are useful for calculating the collisions of bullets with levels and objects, or for representing the line of sight of an enemy to detect if they can see the player. "


It stats within there that "will return the number of the object hit first" is this true as this doesnt seem to be the case?

Hope you can help
Andy
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 4th Jan 2013 12:10
Hi Gibbon28, a Derbyshire lad eh? I'm just outside Derby

You can use Get3DVectorXFromScreen and the Y&Z versions to get a unit vector from the camera position towards the point in 3D. If you multiply these by a distance you will get a point in space in that direction.

If you use the camera position and the camera position PLUS the vectors you just made with a raycast it should return the objects you are expecting.

I did find a bug which was returning the first object detected every time which Paul has since fixed (should be in Beta v1086 just released).

Here is a "simple" example of using this method of detection using the mouse position:



this.mess = abs(sin(times#))

Login to post a reply

Server time is: 2024-11-24 06:36:34
Your offset time is: 2024-11-24 06:36:34