• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Windows Paper Mario Styled Combat

9

9th_core

Guest
First of all: I know I said that I need to learn to code, and that I was actually planning, but I just can't get the damn "press a key when touching the enemy to do the attack again" thing right.
I tried to check if collision with the enemy and pressed Z, it does the attack again. Yes, it works. But after the enemy is dead, I get an error that says that it can't find "enemy.x" because I destroyed it.
Thanks! :)
 
D

Dudeidu

Guest
You should always check if the instance exists before referring to it in another.
So before your "if collision" statement, use "if instance_exists(enemy)"

Also, if you got more than one enemy sharing the same object name, you should refer to its ID instead of its name.
 
9

9th_core

Guest
Okay guys. I made a new game because the other one was in full "drag and drop" things, and I did a code. This is it:

if instance_exists(obj_Enemy) {
if keyboard_check_pressed(vk_up) {
instance_position(obj_Enemy.x,obj_Enemy.y - 128,obj_Player);
gravity = 0.5;
if !place_free(x,y + 1) {
EH = EH - 1;
}
}
}

It works, but the obj_Player won't go to obj_Enemy.x or obj_Enemy.y - 128.
 
A

Aura

Guest
That code currently does nothing. It returns the ID of the player instance if it's colliding with a random enemy instance. You're not even capturing the ID.

What exactly are you trying to do? How is the player instance supposed to move?
 

Bingdom

Googledom
That's an incorrect way of using instance_position.
Instance_position is a collision checker.
Quote from manual
Checks for a collision with the specified object at a specific location and returns its id.
If you want to modify the player's position consider changing the x and y variables instead.
 
9

9th_core

Guest
That code currently does nothing. It returns the ID of the player instance if it's colliding with a random enemy instance. You're not even capturing the ID.

What exactly are you trying to do? How is the player instance supposed to move?
Thanks for telling me!

That's an incorrect way of using instance_position.
Instance_position is a collision checker.
Quote from manual


If you want to modify the player's position consider changing the x and y variables instead.
Thanks for telling me!
 
Top