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 / ObjectRayCast() not working?

Author
Message
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 19th Feb 2014 23:33
Not sure if ObjectRayCast works properly.
It works for one object and not another and also the mode for checking against all objects doesn't work at all.

I don't expect to see this fixed, but it seems a bit weird. Maybe there's something I have done to the second model that means it doesn't work?

29 games
19
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 20th Feb 2014 15:30
I've not had any problems with the 3D collision commands but didn't realise there was a mode for checking all collisions.

What version of AppGameKit are you using, I'm on V108.2 (but really need to download the latest and greatest), and if you upload an example I should be able to look at it today or tomorrow.

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 20th Feb 2014 20:50
i believe it use the collision list.
are the other objects have SetObjectCollisionMode on?
maybe try ObjectSphereCast with radius.
and be sure your surface normals are correct.
or show us example code with your issue.

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 21st Feb 2014 00:51 Edited at: 21st Feb 2014 00:52
Looked at the SetObjectCollisionMode (I wasn't using it). Set it to 1 and no difference.

Other objects without this set work fine.
How do I know my surface normals are "correct" ?

Spherecast is no good, as it's supposed to be causing a light occlusion.

[edit] I'm using 108.19

29 games
19
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 21st Feb 2014 22:51
Generally you'd check the normals in some 3D modelling software. However, if they're pointing in the wrong direction you would see this when the model was loaded into AppGameKit (the face would be invisible or the model would look "inside out".

It could be that there are gaps in the model but then you'd see intermittent failure with the collision checks. It could be some weird disconnect between what you seen on the screen and the actual vertex data (I've seen this once where someone had a model that was visually 90 degrees to the actual vertex data).

I know you can't use sphere casting for what you ultimately want to do but it's worth having a go as it would help to narrow the problem down.

Is this just happening with a particular model? Is it possible to upload it for us to have a look at?

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 22nd Feb 2014 10:27 Edited at: 23rd Feb 2014 12:58
edit:
hmm, i agree, i get only the first object!?
(but setcollisionmode was important.)



AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 22nd Feb 2014 12:42
SetCollisionMode is probably on by default (I didn't disable it, more like didn't set it to anything).

I also don't mean multiple objects hit in the same raycast (although I did try this); I mean something like this where I check for specific objects:



Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 22nd Feb 2014 19:50 Edited at: 22nd Feb 2014 19:51
maybe try paint the pos. with drawline in 2d,from top or side.
from,to + object the ray should hit.

or print("...") the parameters from raycast on screen.

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 22nd Feb 2014 20:43
I drew a line from the sun to the middle of the screen and it all lines up - can't get this model to work with raycast at all, so I uploaded it now if you can check it?

Attachments

Login to view attachments
29 games
19
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 23rd Feb 2014 03:39 Edited at: 23rd Feb 2014 04:28
I think you may have misunderstood the "GetObjectRayCastNumHits" command. From what I understand it returns the number of calculations performed to come up with collision coordinates and not the number of objects that are intersected by the ray cast.

edit: just having another look at the help files, I don't think that's right and I'm going to say that I don't really know what that's all about or how to use it.

from the help file for "GetObjectRayCastNumHits"
Quote: "Returns the number of collisions that occurred in the last collision check. In the case of ObjectRayCast and ObjectSphereCast this will be 0 or 1. For ObjectSphereSlide this could be anywhere between 0 and 4."

But if ObjectRayCast and ObjectSphereCast only have 0 or 1 "hits" then it doesn't seem to be accounting for multiple objects.

Anyway, moving on:

@ nz0, I tried your model and it work perfectly on v1 V108.2. I've created a couple of examples using it. The first will return the id of the first satalite hit and the second loops through all the satalites:





Apart from that I don't know why your code wouldn't work.

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 23rd Feb 2014 12:42 Edited at: 23rd Feb 2014 12:57
@29games
hmm, maybe, i just expect something else.
i think the ray stops until find first object.

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670

Login to post a reply

Server time is: 2024-11-25 02:26:32
Your offset time is: 2024-11-25 02:26:32