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 / Help With RayCast for sprites

Author
Message
Game_Code_here
3
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 27th Sep 2021 03:35 Edited at: 27th Sep 2021 03:50
I am using this code here from a example, it works on its own but not with my game.

I am trying to ray cast the same group but nothing happens.

Here is the code I am trying to use.



Attachments

Login to view attachments
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 27th Sep 2021 06:43
Can you post more of your code? Is your ray the proper coordinates you want? Looks like you could delete the player. I also can't see any purpose for decrementing ThisGroup based on that code snippet.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Game_Code_here
3
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 27th Sep 2021 09:05 Edited at: 27th Sep 2021 09:08
Im using this example




My Player and enemy are in the same group, I'm not sure if that matters

But I am just using trigger box for the collision, looks like it works ok

The code I showed above is the whole thing related to what I need.

Thanks for your time

I do need one more thing if you can?

How do you check a impulse to slow down the movement of a sprite with SetSpritePhysicsImpulse?

SetSpritePhysicsImpulse( player, GetSpriteXByOffset(player), GetSpriteYByOffset(player), GetVirtualButtonState(2)/0.10, 0.0 )
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 27th Sep 2021 13:27 Edited at: 27th Sep 2021 13:27
Looks like your ray is cast from a local static position, it should be cast from player position +

Quote: "I do need one more thing if you can?"


I use this for a top down


but platformer you might want to take a different approach and just check the x velocity, y is your jump so as long as gravity is applied your y velocity should be capped

Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
Game_Code_here
3
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 28th Sep 2021 01:56
PartTimeCoder

Thanks for your help.

I have just one more problem

I am rotating a coin sprite but its not rotating around, its rotating in a spin.

SetSpriteAngle( allcoins, GetSpriteAngle( allcoins )-90 + (GetFrameTime()*500))
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 28th Sep 2021 11:06
You mean its rotating from the 0,0 xy??

Use SetSpriteOffset, set the centre of the coin as the offset (spritewidth/2, spriteheight/2). now it should rotate around its centre
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee

Login to post a reply

Server time is: 2024-04-27 02:35:05
Your offset time is: 2024-04-27 02:35:05