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.

Newcomers AppGameKit Corner / Simple box collision ?

Author
Message
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 19th Dec 2015 18:46 Edited at: 21st Dec 2015 16:58
Hi

I would like to know if there is simple box collision method ?
I have tried raycast (sphere or without sphere) and it doesn't work.

If I try with my player (a box (15,45,15)) and other objects (some box or rectangle, it doesn't work in all cases).


EDIT :
I would like informations about 3D collisions, not sprite 2D .
AGK2 tier1 - http://www.dracaena-studio.com
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 20th Dec 2015 17:24
Sprites are assigned a box shaped hit-box by default so all the basic sprite collision commands will use that. Not got the manual with me so can't remember the commands but something like GetSpriteHit() should work. You can then, via a command, (something like SetSpriteShape?) change the hitbox to be a circle or polygon.
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 21st Dec 2015 16:57
Sorry, I have forgotten to precise in 3D, not with sprite, but with 3D object ^^.
AGK2 tier1 - http://www.dracaena-studio.com
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 21st Dec 2015 17:54
ah! Over to someone else...
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)
Crazy Programmer
AGK Developer
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Lost in AGK
Posted: 21st Dec 2015 18:47
Quote: "(a box (15,45,15)) "

looks 3d to me

I have been watching this since you posted it, i dont know if i understand what you are trying to do but i will guess.

If some object collisions are working and some are not. My first guess is you havnt set 3d physics on all objects. That is if you are using the built in physics.

Beta Test Age of Knights:https://play.google.com/apps/testing/com.CrazyProgrammerProductions.my_AgeOfKnights
Download JellyFish Dive:https://play.google.com/store/apps/details?id=com.CrazyProgrammerProductions.my_JellyFishSwim
Yodaman Jer
User Banned
Posted: 21st Dec 2015 20:57
As far as I can tell, there is no default Collision Box command, outside of the new 3DPhysics commands. You may want to have a look at them and see if that will provide the solution you're looking for.

Sign up for NaGaCreMo!
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 22nd Dec 2015 09:22
HI

Thank you for your answers.

In fact, I use Raycast to check for collision.
It works fine if the character and the bonus have the same sort of box-shape, but it doesn't work no more if their box-shape is different (squarre/rectangle for example) :
AGK2 tier1 - http://www.dracaena-studio.com
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: 22nd Dec 2015 19:32
The first thing you need to do is put this SetErrorMode(2) line of code at the top of your code.
You need to use this line to get error reporting. The commands objectRayCast() and ObjectSphereCast()
are not 3D physics commands. Looks like you are trying to move a 3D physics STATIC object. You can not move them
they are static. If you want to move them make them kinematic. If you want to do ray casting against 3D physics objects use the
3D physics ray casting commands.

p.s. If you set the error mode it will report that you did not create the 3D physics world.
The coffee is lovely dark and deep,and I have code to write before I sleep.
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 23rd Dec 2015 09:11
@Stab : thanks, I will use SetErrorMode(), I didn't know this function.
In fact, I don't want to really use the physics functions, I just want to have "collision" check : real (physic) or "virtual" (like : if box.x+box.w >= box2.x and box.x+box.w<= box2.x+box2.w) or (box.x>=box2.x and box.x<=box2.x+box2.w))

I have used ObjectSphereCast(BonusID...) with BonusId as objID and it works, even if I have prefered a general technic ^^.
I know I use Static as dynamic, but in my game, I use the Character functions and dynamic object dosen't work with character functions. Only Static physic work, so 'im forced to use static object and create their static physic each frame.
Do you know how I can use chracter functions with dynamic/kinematic physic objects ?
AGK2 tier1 - http://www.dracaena-studio.com
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: 23rd Dec 2015 15:05 Edited at: 23rd Dec 2015 15:06
The character controller interacts with static, dynamic and kinematic objects.
Kinematic objects interact with dynamic and character controller objects but do not interact with static objects.
In your code you are moving a static object and recreating it so the collision shape is moved to the new location.
Recreating the static object repeatedly will slow down the physics. Kinematic objects do not have to be recreated to
update their collision shape it is handled by the physics engine. Dynamic objects are handled by the physics engine and
can be moved using the velocity commands. The 3D physics has contact report commands which will return collision checks.
If you do not use the SetErrorMode() command use debug when you build and the errors will be in the debug window.
In case you are curious how I know about the 3D physics, I integrated the 3D physics in AppGameKit for the game creators.
If you post an example of how you are using the character controller commands I can help you.
The coffee is lovely dark and deep,and I have code to write before I sleep.
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 24th Dec 2015 07:23
@Stab : thanks again, you're right.
In my previous test, my character-object didn't work with kinematic and dynamic object, but in my new test, it works.

Here is a new code (I have use one of your examples for the character ) :
Do you know how the character can move the yellow box ?
And How I can detect collision between the player (objid =1) and the others objects ?
Because it's a character, I think I can't use contact.


For the moment, I use : id = ObjectSphereCast(objid, oldx, oldy, oldz, NewX, Newy, NewZ,20) for all type of object (I change objId by their id), but I would like to use a "general" code (like : id = ObjectSphereCast(0,oldx, oldy, oldz, NewX, Newy, NewZ,20))

Thank you for your help.

Thanks again

AGK2 tier1 - http://www.dracaena-studio.com
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: 24th Dec 2015 15:16 Edited at: 26th Dec 2015 15:15
Try this code, The explanation is in the comments in the code.
Have a Happy Holidays.



EDIT: ObjectSphereCast() should not be getting a hit on an invisible object. This may be a bug.
The coffee is lovely dark and deep,and I have code to write before I sleep.
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 29th Dec 2015 13:58
Thanks for your example and explications
AGK2 tier1 - http://www.dracaena-studio.com

Login to post a reply

Server time is: 2024-11-23 22:13:40
Your offset time is: 2024-11-23 22:13:40