Missile velocity

I wrote up some code to predict whether an enemy missile is dangerous, and when it will hit, etc. but I assumed that missiles had a velocity member, which it seems they don’t. I could compute it myself based on rate of change of position, but cycles are at a premium. Is there a built in way to get the velocity of a missile?

1 Like

Hmm, it’s just missile.velocity. It’s possible that some missiles don’t have the API configured properly; I know Shells have it (at least they do as of yesterday). Which missiles weren’t working?

Spears. I’ll give it another try, maybe I just goofed somehow.

I just realized I hadn’t hooked up the APIs properly to most of the missiles. I think I got them all now.

Although this thread is very old, I try my post here, because I have also a ‘velocitiy’ problem with a missile type.
Playing ‘Sarvan Treasure’ on level 4 (or 5?) involves lots of ‘razor-rings’ flying around and although I have enough armor to survive them currently, I would like to dodge them.
Therefore, I would need the ‘velocity’ property, but apparently it is not available. E.g.

hero.say(missile.velocity.x)

results in a ‘TypeError’ ( while e.g.

hero.say(missile.type)

at the same location works)

Am I doing something wrong or is ‘velocity’ not implemented for 'razor-ring’s ?

Hmm, it should be implemented: https://codecombat.com/editor/thang/razordisc-missile does list velocity in the HasAPI Component. Is it possible that there is some other type of the missile existing in the level at some point that might be missing velocity?

1 Like

@nick the Headhunters actually use Razor Ring instead of Razordisc Missile. (The latter is for the ranger item-version). It turns out the Razor Ring is actually missing the velocity property in hasAPI. I’ve sent a patch that adds velocity to the API :+1:

3 Likes

Wow, great catch! Implemented, give that a try (might need a cache clear).

2 Likes

I can confirm the velocity property can now be accessed. Thanks @nick :+1:

2 Likes

Yes, it’s working!! :slight_smile: Thank you very much!!