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 / collision between 2 3d objects or more

Author
Message
haliop_New
User Banned
Posted: 11th Jan 2017 11:39
is there a better way ?

currently I'm using objectraycast and objectspherecast but because the level is very curved it sometimes gives me bad results.
if I could curve the ray cast it would be awesome but I'm afraid this cannot be done without testing for multiple raycasts each time a little bit , the problem with that is that I'm trying to keep the cpu usage at very low power ...
I wonder if there is a collision checking without using the 3d physics commands since they are too slow
if i'll add a physics attribute to each block in my game the game will run slow since there are hundreds
now I could try 2 things
one checking 3d distance between my player and the blocks
or checking to see positions using if x< x1+width/2 and x > x1-width/2 etc..
but on both cases I will have to irritate trough the whole array and I don't want that
objectraycast gives me the correct id of the given hit and I keep the blocks at 1 to 200 id's
CreateObjectBox(myId,width,height,depth) well not exactly like that but very similar
so I can check really quick the collision.
but I wonder if there is a command such as
ObjectHit(playerId,0) // 0 for all objects
or
ObjectCollision(playerId,0) // 0 for all objects

thank you for your time, haliop.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 11th Jan 2017 11:50 Edited at: 11th Jan 2017 11:53
i believe this objectraycast based on the colllision flag, if you disable the out of range objects it will be fast.
SetObjectCollisionMode ( objID, mode )
ray cast also belongs the distance, short distance should be faster than endless because at far distance all objects need a check.
for your curved track i would use a ray cast in steps and exit if the first hit occur.
test only the distance which your ship travel each frame.
AGK (Steam) V2017.01.09 : Windows 10 Pro 64 Bit : AMD (16.12.1) Radeon R7 265 : Mac mini OS Sierra (10.12.2)
haliop_New
User Banned
Posted: 11th Jan 2017 12:02
so setting objectcollisionmode to 0 on object that dosent need to be checked will fasten my calculations ?
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 11th Jan 2017 12:10 Edited at: 11th Jan 2017 12:14
I think so.
normal the first sort is by bounding box or sphere, if the ray passed through then the triangles are tested.
point in triangle is much math and slow.

a fast collision test is sphere to sphere.
AGK (Steam) V2017.01.09 : Windows 10 Pro 64 Bit : AMD (16.12.1) Radeon R7 265 : Mac mini OS Sierra (10.12.2)
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 11th Jan 2017 14:47
Quote: "I wonder if there is a collision checking without using the 3d physics commands since they are too slow"


What makes you think that the 3dphysics commands are too slow?
The coffee is lovely dark and deep,and I have code to write before I sleep.
haliop_New
User Banned
Posted: 12th Jan 2017 10:56
from trying it ,
it lags a lot
fps drops to 30 from 60
it is unusable at my end...
maybe I'm doing something wrong I don't know but everytime I tried using 3d physics on multiple objects like 100 or so the fps drops to 30 even if all of them are static objects...
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 12th Jan 2017 17:08 Edited at: 12th Jan 2017 17:09
100 static objects should not slow down physics maybe an error in code.
Do you have a code example to demonstrate this?
Also what hardware does this occur on? Android, Windows?
The coffee is lovely dark and deep,and I have code to write before I sleep.
Carharttguy
7
Years of Service
User Offline
Joined: 8th Jul 2016
Location: Belgium
Posted: 13th Jan 2017 08:47
A side questions: Why would you need a curved raycast for? I couldn't think of any application for that.
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 13th Jan 2017 17:27
A curve is a series of many vectors, a ray extends along a single vector, even if there was such a thing as a 'curved collison-test cast', it would still require a series of straight line casts internally.
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
haliop_New
User Banned
Posted: 14th Jan 2017 08:16
Ortu , yep I know I'm trying to figure out what is the best collision method I could find... or create...
I could try hmm

I have a max of 200 blocks in any time
I could

do this



this way I'm not using raycast at all and not irritate all of the blocks at once only 5 each frame , I run on solid 45 fraps so it unnoticeable.

so its a matter of testing to see which is fastest , the problem I'm having with the ray cast is :

I have a spaceship arcade game where you speed up and avoid blocks along the way , the track can be very curvy(English second lang.. I'm trying to find a better word maybe slope)
so sometimes the spaceship is turning way to fast so the actually ray cast stays straight and the next block may come from a very high angle so it wont "find it" also i'm using spherecast and still it poses a bit of a problem
also it the track is divided into 3 sections so sometimes it collect coins and other blocks from another route which is not good at all ...

any other thoughts for collision out there I wonder
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 15th Jan 2017 04:39
could you just use a distance check between the ship and nearby objects? It wouldn't matter what angle a block was coming from. Once you detect an object within collision proximity, you could then cast against that object's position for hit precision.
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
haliop_New
User Banned
Posted: 15th Jan 2017 10:08
Yeah i think i can do that

Login to post a reply

Server time is: 2024-04-25 21:31:36
Your offset time is: 2024-04-25 21:31:36