YesNoOk
avatar

Getting a Helper or Projectile to Aim At Other Helpers? (Read 20761 times)

Started by Afterthought, March 16, 2018, 04:44:33 am
Share this topic:
Re: Getting a Helper or Projectile to Aim At Other Helpers?
#21  March 16, 2018, 05:18:50 pm
  • avatar
  • **
Quite frankly I put exactly what was suggested. I'm not entirely sure what equations TO use for the X velocities. Obviously I'm not asking anyone to hold my hand with this, I'm simply going with what's being suggested. I was under the assumption that upon being spawned, these helpers would have their positions set automatically, so the code you shared would solve the rest.

EDIT: Just read your revisions, ODB: I did have those variables set to 1 in different statedefs; removed. 1208 does move now, albeit too quickly.

What I need now is for it to actually STOP upon hitting a helper, then take course to the next helper in line.

EDIT 2: Since what I'm doing isn't necessarily a secret anymore, I suppose I can show a video to show where I'm at currently.

https://youtu.be/Oyu-Fx3MkSo

The velocity of 1208 is indeed affected by the presence of the other two helpers. Just not in the way I need. I was hoping it wouldn't get more complicated than it already is, but I'm not afraid to get my hands dirty.
Last Edit: March 16, 2018, 06:00:05 pm by Afterthought
Re: Getting a Helper or Projectile to Aim At Other Helpers?
#22  March 17, 2018, 10:46:38 pm
  • *****
  • Shame on you!
    • USA

  • Online
The way I usually work out how to obtain my speed(s) when working on stuff like this is to do the math backwards.
You know how fast you want it to move.
You know you're going to get some values.
So all you have to do is figure out what to put as an equation to get those values to equal the speed you want.
Usually if you know exactly the speed and you just need to see if var(32) is active you could just use an IfElse and activate the set speed.
Because you're going to target with X and Y values setting X = 5 may be too fast if Y also = 5, because you have a speed of say 10. You only want it going a total of 5 so you'd need X = 2.5 and Y = 2.5

You need to look at the values in debug. They're clearly waaay to fast. You can do simple division to make it slower or get a little more complex.
If you look at how my Samus' missiles are set up, they have a set maximum speed I check for. Expect your state to get filled up with code. This isn't some rookie stuff. Heck, my changeanim block of code is like 80 lines.
One thing you can do is just adjust the Y like I do. This is from my Samus.
Spoiler, click to toggle visibilty
You can see I set a certain range the speed can go. The X speed is constant and only the Y gets adjusted. This may make it easier on you, But I think you want the speed to increase as it hits one to the next?? You can do this by setting it's animation if it connects, then set the X speed based off of it's animation. It's a way of skipping a variable to keep track.
You could easily adjust this where you set the animations to be a few values apart. Say if you wanted the speed to increase 2 you'd set the animations to say
1600, 1602, and 1604.
The math would be
(Anim-1600)+Var(32) so it could be 0+Var(32), 2+Var32), or 4+Var(32)
if you wanted the gap to grow, up the animations. Say 1600, 1603, 1609. 0, 3, 9. If you wanted it to grow a lot smaller,
((Anim-1600)/2)+Var(32) at 1600, 1601, 1602.
What ever works best for the speed you need.

Try setting a low X speed, then adjust your Y. If the orbs can go backwards You'll need to figure out for X too. You could set a small range for low speed. Like if the X distance is with-in say 50, then you'd use that value to bring it down, anything above -50, or 50 you'd use X = 3 or whatever.

But keep track of your distances using Debug. Plot them on paper so you get an idea of how far apart they are on screen and what those values are and what they max out. Once you have your max value, find your minimum value. That's your range for your math. Then you have to adjust that scale down to the scale of the actual speed you want. It's simple yet hard.
vVv Ryuko718 Updated 10/31/22 vVv
Re: Getting a Helper or Projectile to Aim At Other Helpers?
#23  March 17, 2018, 11:15:11 pm
  • avatar
  • **
I'm honestly not convinced at this point that it's a speed issue, so much that it's an issue with the helper actually finding the other helpers and MOVING to them instead of in different directions, which I'm sure you saw in the vid. It doesn't seem like it's tracking them; it acknowledges their existence, yes, but as for actually going in their general direction, not so much. Then of course there's the matter of it realizing there is in fact more than one and moving to the closest first; I need to study the code you shared in regard to finding which is first.

(Thanks for the spoiler post edit by the way.)
Re: Getting a Helper or Projectile to Aim At Other Helpers?
#24  March 17, 2018, 11:44:46 pm
  • *****
  • Shame on you!
    • USA

  • Online
The code I posted is just the over-all IDEA. All of the values to go toward the first thing is up to you.
You need to spawn the Helper M with NO velocities and see the var(32) and var(33) net you. Restart the round, and put the orbs in different spots on the screen. Move around and see if the values change.
My math is no where near right for you. It was meant as a Prof of Concept honestly.

Maybe focus on getting it to head towards 1. And once you get it to go to that one, you set it up so it looks at the distance between itself and the 2 and picks. Then you'd just put that number in the code that you know gets you to the orb. Once it's there, you use the other var to go to the second one.

Like I said, this is pretty complex so you're going to want to build it up brick by brick.
vVv Ryuko718 Updated 10/31/22 vVv
Re: Getting a Helper or Projectile to Aim At Other Helpers?
#25  March 18, 2018, 11:01:06 am
  • avatar
  • **
I figured it'd be hefty. I'll have to make some time to sit down and try to wrap my head around it, I realize there's no shortcuts. Thanks for your input, it definitely helps me see just how complex code can get.