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 / detection of a collision between a physics sprite and a normal sprite - tier 1

Author
Message
samqweqwe
11
Years of Service
User Offline
Joined: 7th Apr 2013
Location:
Posted: 6th Aug 2013 17:50
hello im quite new to agk and i need to detect a collision with a physics sprite and a normal sprite
i am currently using GetSpriteCollision but i am not sure if it is working. i also know of the GetPhysicsCollision function but i dont think that will work as only one object is a physics sprite.

does GetSpriteCollision work for a collision with a physics object and a non-physics object?
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 6th Aug 2013 19:08
Can't see why not off the top of my head. Perhaps some code may help determine the problem? I have a collision video in my tutorial thread, but it does not use physics. However, I have done other projects with a combination no problem.

samqweqwe
11
Years of Service
User Offline
Joined: 7th Apr 2013
Location:
Posted: 6th Aug 2013 19:19 Edited at: 6th Aug 2013 20:27
thanks for the reply.

heres the code:


this then activates this:


but only the big bat seems to work?

another small problem i have (nothing to do with the code above) is the speed for the ball. i have to sort the speed:


but however high i put the random values it never gets any faster eg random ( 1000, 2000 ) * 1000
any suggestions on how to fix this?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 6th Aug 2013 23:36
I think you'll have to make it a physics sprite too. You can always make it kinetic and make it a sensor if you don't want other sprites to react with it...


Yes, he's me
lilpissywilly
AGK Developer
13
Years of Service
User Offline
Joined: 10th Sep 2010
Location: Office Chair
Posted: 7th Aug 2013 08:59
I agree with \ ^

You can try "GetSpriteInCircle" or "GetSpriteInBox" too if you want. Using the coordinates from the bat when you check for collision. Kinda depends on how the bat looks if this would work or not, or if you wanted a specific part of the bat to be hit it would work good too.

My hovercraft is full of eels
samqweqwe
11
Years of Service
User Offline
Joined: 7th Apr 2013
Location:
Posted: 7th Aug 2013 15:08 Edited at: 7th Aug 2013 15:09
thanks for the help! its working now

but does anyone know why the ball isnt going any faster with a higher velocity?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 7th Aug 2013 17:15
I believe there is a finite limit to velocity. You may need to change the scale of the physics world to suit your project using setPhysicsScale(value#)

Make sure you do this before you create any sprites or use any other physics commands


Yes, he's me
samqweqwe
11
Years of Service
User Offline
Joined: 7th Apr 2013
Location:
Posted: 7th Aug 2013 17:29
that explains why i have to use such high values for physics, thanks

Login to post a reply

Server time is: 2024-04-27 06:25:21
Your offset time is: 2024-04-27 06:25:21