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 / GetObjectRayCastNormalY() always returning zero

Author
Message
JohnStabler
AGK Bronze Backer
10
Years of Service
User Offline
Joined: 16th Aug 2013
Location: Cardiff, Wales, UK
Posted: 14th May 2017 22:13
I'm casting a ray at an object (a wall) and I'm using the ray cast normal functions so I can create and orientate a bullet hole plane object. The GetObjectRayCastNormalX() and GetObjectRayCastNormalZ() functions seem to be working, but GetObjectRayCastNormalY() always returns zero. Is anybody else able to recreate the issue?
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 15th May 2017 19:44
Maybe because you are hitting it "dead-on" so there is no Y value either way?
Try altering your angle a little on the Y vector?

29 games
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 15th May 2017 20:01
It probably that the wall is perfectly vertical. Even if the raycast came in with a downward angle, for example, then the Y normal would still be zero (the Y bounce would be different though).

Here's a quick demo:



If you swap the sphere for a cube then all the normals will be at right angles (i.e. one of the normal will be 1 or -1 and the other two will be zero).
Hover Car Race Challenge! - available now on Google Play
Invaders of the 29th Dimension - available now on Google Play
Find me on indieDB
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 16th May 2017 09:32
my decal example
AGK (Steam) V2017.03.31 : Windows 10 Pro 64 Bit : AMD (17.2.1) Radeon R7 265 : Mac mini OS Sierra (10.12.2)
JohnStabler
AGK Bronze Backer
10
Years of Service
User Offline
Joined: 16th Aug 2013
Location: Cardiff, Wales, UK
Posted: 16th May 2017 11:40
nz0: I've got a fully working FPS camera working so I have been able to shoot it from all sorts of angles.

29 games: thanks for the sample.

markus: Your code has me thinking I'm doing it wrong. I'm using SetObjectRotation() but your use of the position + normals with SetObjectLookAt() might give me the proper result. I'll change it tonight and let you know.

Thanks for everyone's help!

Login to post a reply

Server time is: 2024-04-26 14:10:54
Your offset time is: 2024-04-26 14:10:54