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 / Follow Sprite Logic Help [Tier1]

Author
Message
Zeerun
AGK Developer
19
Years of Service
User Offline
Joined: 28th Aug 2005
Location: United Kingdom
Posted: 27th Oct 2015 09:42
Hi,

I am having problems getting my head around my function to have a sprite that is always just past the bottom right of my player sprite, which I am wanting for platform collision detection, what I have is fine up until 90 degrees, but after that (when the sprite angle is 0) things go awry.

Any help would be much appreciated!

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 27th Oct 2015 11:43
If you want to allow an offset in X and Y you need to do some slightly more complex maths but there is an easy way... take a look at the commands:
GetWorldXFromSprite( iSpriteIndex, x, y )
GetWorldYFromSprite( iSpriteIndex, x, y )

Much easier than all that fiddly maths
Using AppGameKit V2 Tier 1
lilpissywilly
AGK Developer
14
Years of Service
User Offline
Joined: 10th Sep 2010
Location: Office Chair
Posted: 27th Oct 2015 14:13
Or use raycast?
My hovercraft is full of eels
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 27th Oct 2015 15:16
Baxslash's suggestion looks good to me. Does this work:


I make a little test and see...
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 27th Oct 2015 15:35
Looks good to me... Usage example:


V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Zeerun
AGK Developer
19
Years of Service
User Offline
Joined: 28th Aug 2005
Location: United Kingdom
Posted: 28th Oct 2015 09:05
Thanks for all the replies,

Get world from sprite is very elegant! It has worked great

CJB: thanks for the effort in making a working snippet! You should share it to the snippet thread, I am sure it would help others too.

I will get a WIP up soon, just need to rewrite the gravity inversion logic now that I've ditched physics, (Going for a sonic style endless runner with loops, inversions and being able to flip from floor to ceiling)
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 28th Oct 2015 09:10
Glad to be of help! I hope it was of value (valued member badge? nudge nudge ).

I like the game idea. Looking forward to seeing a demo.
V2 T1 (Mostly)
Phone Tap!
Uzmadesign

Login to post a reply

Server time is: 2024-11-17 00:57:18
Your offset time is: 2024-11-17 00:57:18