Coding: Boomerang projectile (Read 3055 times)

Started by Redash, March 14, 2018, 05:39:42 am
Share this topic:
Coding: Boomerang projectile
#1  March 14, 2018, 05:39:42 am
  • avatar
  • **
    • Singapore

I coding a projectile that can move back and can hurt both friend and foe.

I have figured out the vel X part by using veladd and helper-type projectile. (If velocity of projectile can be change on a Projectile-type projectile pls let me know)

However i have no idea how to code on 2 issues:
1st issue:
 the hit velocity of target hit when it is moving forward and when it move backward (returning)
- the issue here is when it hit a target when it is moving forward, the hit velocity is -ive, but when it hit a target when it is returning the velocity should be +ive.

What i coded is:
Ground.velocity = Cond(vel X < 0, 4, -4)

But shockingly... the target upon hit will always be -4, cuz vel = 0; by means of displaytoclipboard, i discover when movehit or movecontact = 1, vel X becomes 0 (>_<)

2nd issue:
As i use a helper-type projectile, i also use hitoverride, i also no idea what to code for the trigger for Scrtl: Turn.

Similar to above i initially code as:
Trigger1 = helper(#),vel X < 0 ; for change in direction of travel

This is so that the hit anim is display correctly depending on direction to hit.

Pls advice what should i be coding in the triggers.
I tried to use pos X and var(#) to save the Vel X just before it hit a target but it is inconsistent.

If there are any relevant chars with boomerang projectiles pls kindly link me to them.

Last Edit: March 15, 2018, 09:50:48 am by Redash
Re: Coding: Boomerang projectile
#2  March 14, 2018, 08:09:31 am
  • *****
  • Shame on you!
    • USA
You may be able to use Facing to figure out if it should be positive or negative.
ifelse(facing =-1, 4,-4)
see if facing is working for you. Post it to your clipboard. Not sure if you change which way it's facing or not but it seems like a possibility.
What triggers do you use to tell when to change it's speed and direction. You can base your hit reaction off of them?
Like if you make it come back after 75 tics, you can just use that in the hitdef?

What triggers are you using to adjust your speed? It seems like you're using a veladd or something if you're checking for vel x < 0.
To turn your animation, I'd suggest making 2 animations. Even if they're exactly the same. Then you'll want to use your veladd triggers to swap animations. Based off the animation, you'd use turn. In the Turn, you'll want to use persistent so it only happens 1 time.
vVv Wheat Stage Released vVv
Re: Coding: Boomerang projectile
#3  March 15, 2018, 09:50:36 am
  • avatar
  • **
    • Singapore
Thanks Odb718. Problem solved after i duplicated another state just for the returning projectile.

Though i have to state that it is like a dirty fix since i have to reduplicate a new statedef with all states and attrs just to have another different ground.velocity X values

Funny that Cond(fvar(#) < 0, 5, -5) isnt working despite fvar(#) is proper value...

Other sharing: discovered projectile velocity is -0.0 when halted, so vel x = 0 will not work properly @_@