|
Post by the1 on Sept 24, 2017 21:53:11 GMT
I was wondering, How could I make a script were, When My projectile shoots, Event on contact with the enemys hitbox it will subtract an amount of health. Also I need it to use envent on value to stop Ai And Projectile and start death animation. I mostly need the script though because I already know how to do everything else
|
|
|
Post by indiedev on Sept 25, 2017 4:31:50 GMT
no script=counter object
|
|
|
Post by GH Games on Sept 25, 2017 11:51:34 GMT
indiedev is right, however if you still want to use a Script this might work for you.
I have made it so you can manage multiple enemies. To do so just create new variables for Enemy 2, 3, 4 etc and create a new instance of the ManageEnemyHealth() function, passing it the required parameters. You can see how to do that by the example one I have made.
It's untested but should work.
int Projectile = OBJ_XX;
int HitDamage = 10;
//Enemy 1's Variables float Enemy1Health = 100; int Enemy1AI = OBJ_XX; int Enemy1HitboxForce = IN_XX; int Enemy1AnimationSet = OUT_XX;
void Main() { ManageEnemyHealth(Enemy1Health, Enemy1AI, Enemy1HitboxForce, Enemy1AnimationSet); }
// Manage Enemy Health Function void ManageEnemyHealth(float health, int enemyAi, int hitboxForce, int animationSet) { if(hitboxForce > 0 && health >= 0) { health -= HitDamage; } else { health = 0; // So it doesn't go to the negative numbers iObjectStop(Projectile); iObjectStop(enemyAi); animationSet = X; // Where X equals the death animation for all enemies } }
|
|
|
Post by the1 on Sept 26, 2017 23:16:44 GMT
Whats A Counter Object
|
|
|
Post by indiedev on Sept 27, 2017 10:42:58 GMT
hint: similar to an EventOnContact object that you would also need
|
|
|
Post by the1 on Sept 27, 2017 23:38:46 GMT
How Would I get Around to using it. I know event on contact (STOP) All the components but how could I do the health mechanic, hopfully without script
|
|
|
Post by TinSoldier on Sept 28, 2017 1:17:53 GMT
|
|