GameMaker: Studio

GameMaker: Studio

View Stats:
Kill enemy by jumping on it head
So I want to jump on an enemies head and kill it, and take damage if i touch it from the sides etc.

So i have set this up as

variable, If direction is greater then 225
destroy instance

else

take damage basically.

but i cant seem to kill the enemy, i just take damage. I will upload a screenshot of what I have when imgur is working again. But if anyone can help out with what the problem could be, it would be very helpful


http://imgur.com/2i7CvkM
Last edited by Donna Pinciotti; May 21, 2016 @ 10:04am
< >
Showing 1-14 of 14 comments
woods May 20, 2016 @ 5:25pm 
quick thought in the dark... relative check to player or to enemy?
if its not set to enemy, it would read direction 225 to player?
Donna Pinciotti May 20, 2016 @ 5:35pm 
I am using the drag and drop icons. and the test variable is set to self, so i assume that is player.

Sorry im not really good at understand coding, but i think that is what you mean :sfsmile:
PeepoSalmon May 21, 2016 @ 5:26am 
make the head a seperate object to follow the body, when the player makes contact, damage will be taken
Donna Pinciotti May 21, 2016 @ 10:04am 
finally got imgur to work so this is the set up i have for it


http://imgur.com/2i7CvkM
woods May 21, 2016 @ 1:04pm 
first glance at your variables..

if dir is greater than 225
if dir is less than 226

how much of a difference between those to numbers?

your target window for hitting and not taking damage is
....ummm -1 pixel ;/


===

i would go something closer to greater than 200 and less than 250(play with your numbers here til you get the proper strike zone) for your first variable and instead of the second variable i would use "else"

that would give you more of a cone shape from the north/up direction for your allowable hit direction
Last edited by woods; May 21, 2016 @ 1:07pm
Donna Pinciotti May 21, 2016 @ 1:38pm 
Oh i thought it would have been anything larger than 225. so everything above 225 would do damage? so say if i hit from then north east side of the sprite it would do damage. I will try changing it around though
woods May 21, 2016 @ 2:08pm 
right is 0 down is 90 left is 180 up is 270 ...

anything greater than 270 is up and right until you get to 360...which is 0


240 to 300 would be a 30 degree window from the up direction

so it would go something like

if direction is greater than 240
and
if direction is less than 300
"rest of action for success"

else
"action for fail"
Donna Pinciotti May 21, 2016 @ 4:50pm 
You mean like this

http://imgur.com/p7JQLlG

sorry for being a pest with this question
woods May 21, 2016 @ 5:33pm 
im definitely not the best guy to be answering questions.. as im very new to coding myself,
but dont worry about being a bother.. isnt that why we are here ;o) to help eachother out and bounce ideas off eachother.

i do know that drag and drop while we can do some pretty cool stuff with it, coding allows way more freedoms to get what we want


this might be of use.. found it last night

if you click on the "show information" button... it will give you the psudeocode for each event for your object.. sometimes reading it in more plain text helps to find some tactical errors


Collision Event with object obj_slime:

if direction is greater than 240
for other object: destroy the instance
set the vertical speed to 0
if direction is less than 300
for other object: destroy the instance
set the vertical speed to 0
else
jump relative to position (-10,-10)


====

what we have here would look something like this...
/// check to bounce on slime's head if (obj_brock.direction >= 240) { instance_destroy() } if (obj_brock.direction <= 300) { instance_destroy() } else { move_towards_point( obj_brock.x-10, obj_brock.y-10, 4) }


Donna Pinciotti May 21, 2016 @ 6:19pm 
Originally posted by woodsguide:
im definitely not the best guy to be answering questions.. as im very new to coding myself,
but dont worry about being a bother.. isnt that why we are here ;o) to help eachother out and bounce ideas off eachother.

i do know that drag and drop while we can do some pretty cool stuff with it, coding allows way more freedoms to get what we want


this might be of use.. found it last night

if you click on the "show information" button... it will give you the psudeocode for each event for your object.. sometimes reading it in more plain text helps to find some tactical errors


Collision Event with object obj_slime:

if direction is greater than 240
for other object: destroy the instance
set the vertical speed to 0
if direction is less than 300
for other object: destroy the instance
set the vertical speed to 0
else
jump relative to position (-10,-10)


====

what we have here would look something like this...
/// check to bounce on slime's head if (obj_brock.direction >= 240) { instance_destroy() } if (obj_brock.direction <= 300) { instance_destroy() } else { move_towards_point( obj_brock.x-10, obj_brock.y-10, 4) }


that causes the player to be destroyed. I think i need to do something with place_meeting , but that does work with direction. Ill try and see what i can come up with . thanks for help
Donna Pinciotti May 21, 2016 @ 6:20pm 
Originally posted by woodsguide:
https://www.youtube.com/watch?v=9LbutnLIj84

this might help ;o)


MMM i did watch this video and tried it this way, but im sure when i did the enemy got destroyed from all areas. I will give it a try again. I may have messed up somewhere. thanks :sfsmile:
Donna Pinciotti May 21, 2016 @ 6:40pm 
well this is how i got it to work (thought id leave it here incase anyone else is looking in the future)


/// enemy collision

if (place_meeting(x,y,obj_brock_standing))

{
if (obj_brock_standing.y < y-6)
{
with (obj_slime)
instance_destroy();
}
}
woods May 21, 2016 @ 7:08pm 
awesome

;o)
< >
Showing 1-14 of 14 comments
Per page: 1530 50

Date Posted: May 20, 2016 @ 5:09pm
Posts: 14