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 / [SOLVED] How to target a sprite from another?

Author
Message
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 29th Nov 2021 14:27 Edited at: 29th Nov 2021 15:15
I'm trying to place an animated sprite between a gun with a turret and enemy sprites, rotating, scaling and positioning it so that it connects the two.
I've been playing with it all weekend but it isn't quite right.

I thought my maths was wrong but this morning I wrote some stand-alone code to isolate the issue and see if I could determine what was wrong but that works perfectly, so the issue is somewhere in my code and I just can't see it.
If any of you have any spare time, would you mind casting your eyes over the code and seeing if you can spot where I'm going wrong?

Here you can see that the targeting is slightly off:


And here is some stand-along code that work perfectly:


And my in game code:
Bullet (lightning) creation:

Bullet Update:


I'm sure it's something obvious but I've been staring at it for so long now that I've gone code blind.
Any help would be much appreciated.

Thanks

Attachments

Login to view attachments

The author of this post has marked a post as an answer.

Go to answer

Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 29th Nov 2021 15:23 Edited at: 29th Nov 2021 15:25
This post has been marked by the post author as the answer.
Solved by Virtual Nomad
It was this line in the bullet update code:

That should have been get the sprites offset positions.
So very obvious but it had become invisible to me!

I'll leave this post here because the "stand-alone" contains some useful code for anyone doing something similar.
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 3rd Dec 2021 05:09
I late on this one but I did that exact same thing in my unfinished atom mash game

heres the function, it uses global type data but it can easily be edited to be generic, it will create the effect from startAtomID to endAtomID, or to the mouse if no endAtomID found, it scales the lightning effect to suit the distance and sets the correct angle, and yeah, I used offsets lol




Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee

Login to post a reply

Server time is: 2024-11-21 12:47:49
Your offset time is: 2024-11-21 12:47:49