• 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!

help with impulse

J

joshua huxley

Guest
I use gm2 and I keep getting this error when I attack my enemy, and I could not find a solution, help please

############################################################################################
ERROR in
action number 1
of Step Eventobj_enemy_slime
for object obj_hitbox:

The instance does not have an associated physics representation
at gml_Object_obj_hitbox_Collision_d5eeb677_f035_4c5b_a7d0_e45a8e87616e (line 10) - physics_apply_impulse(x,y,knockback,knockback);
############################################################################################
this is the code:

if(other.id != creator)
{
other.hp-=damage;
var dir = point_direction(x,y,other.x,other.y);
var xforce=lengthdir_x(knockback,dir);
var yforce=lengthdir_y(knockback,dir);
with(other)
{
//happens inside enemy
physics_apply_impulse(x,y,knockback,knockback);
}
}
 
M

Matt Hawkins

Guest
It looks like you need to make either obj_hitbox_Collision or obj_hitbox a physics object
 
M

Matt Hawkins

Guest
how do I do that?
When you open an object you should see an "Object Properties" window. In this window there is a check box that says "Uses Physics".
Also in your "Room Properties" there is a tab labeled "Physics" with a check box that enables physics in that room, that has to be checked too.
As a rule you shouldn't mix physics code with non-physics code in the same object, You can do it but it can make the physics work incorrectly. It is best to use one or the other.
 
Last edited:
J

joshua huxley

Guest
it's giving me this error now
FATAL ERROR in
action number 1
of PreCreate Event
for object obj_enemy_slime:
Too few vertices in polygon shape fixture for obj_enemy_slime
When you open an object you should see an "Object Properties" window. In this window there is a check box that says "Uses Physics".
Also in your "Room Properties" there is a tab labeled "Physics" with a check box that enables physics in that room, that has to be checked too.
As a rule you shouldn't mix physics code with non-physics code in the same object, You can do it but it can make the physics work incorrectly. It is best to use one or the other.
 

Jezla

Member
It sounds like you're using Heartbeast's RPG tutorial, which I would not recommend. It uses the physics system, which firstly is not really intended for RPG type games, and secondly, is not beginner-friendly. If you're new to GMS, I'd suggest following the tutorials that are included before you tackle something complex like an RPG. If you must make an RPG, then find a tutorial that doesn't use the physics system.

If you're dead set on following Heartbeast, then you need to learn how the physics system works, so that at least you understand what fixtures are, and how forces and impulses work, and how to use and define them. Stop what you're doing and read this series of blog posts and follow along, or load up GM:S 1.x (if you own GMS2 you also own GM:S) and do the physics tutorials that come with it (they're the same as the blog).
 
J

joshua huxley

Guest
It sounds like you're using Heartbeast's RPG tutorial, which I would not recommend. It uses the physics system, which firstly is not really intended for RPG type games, and secondly, is not beginner-friendly. If you're new to GMS, I'd suggest following the tutorials that are included before you tackle something complex like an RPG. If you must make an RPG, then find a tutorial that doesn't use the physics system.

If you're dead set on following Heartbeast, then you need to learn how the physics system works, so that at least you understand what fixtures are, and how forces and impulses work, and how to use and define them. Stop what you're doing and read this series of blog posts and follow along, or load up GM:S 1.x (if you own GMS2 you also own GM:S) and do the physics tutorials that come with it (they're the same as the blog).
thank you for that, can you point out any rpg tutorials that you could recommend?
 

FrostyCat

Redemption Seeker
it's giving me this error now
FATAL ERROR in
action number 1
of PreCreate Event
for object obj_enemy_slime:
Too few vertices in polygon shape fixture for obj_enemy_slime
Your code didn't start with physics in mind, don't use physics_apply_impulse() now. Stop the nonsense and use traditional movement variables.

If you don't have any custom movement variables, set hspeed and vspeed instead of applying an impulse.
Code:
var xkb = lengthdir_x(knockback, dir);
var ykb = lengthdir_y(knockback, dir);
with (other)
{
  //happens inside enemy
  hspeed = xkb;
  vspeed = ykb;
}
If you have custom movement variables like the kind Spalding demonstrates on his tutorials, swap hspeed and vspeed for the equivalent in your code.

And as Jezla said, if you're watching HeartBeast's RPG tutorial right now, STOP! Save the physics system for when you are dealing with realistic physics like those found in Angry Birds or Bad Piggies. And even then, don't use it the way he did.

It sounds like you're using Heartbeast's RPG tutorial, which I would not recommend. It uses the physics system, which firstly is not really intended for RPG type games, and secondly, is not beginner-friendly. If you're new to GMS, I'd suggest following the tutorials that are included before you tackle something complex like an RPG. If you must make an RPG, then find a tutorial that doesn't use the physics system.

If you're dead set on following Heartbeast, then you need to learn how the physics system works, so that at least you understand what fixtures are, and how forces and impulses work, and how to use and define them. Stop what you're doing and read this series of blog posts and follow along, or load up GM:S 1.x (if you own GMS2 you also own GM:S) and do the physics tutorials that come with it (they're the same as the blog).
Damn, if only HeartBeast could see the mess he has made on the GMC and listen to responders like you and I. Not only is his use of physics in that tutorial unsuitable for beginners, his constant brand of abuse of phy_position_x and phy_position_y is unsuitable for just about anyone.

I am beyond sick of cleaning up after HeartBeast's educational malpractice around here. He is the sole reason why novices from the past year can't stop mixing up the traditional movement variables with physics variables. I have not had a vendetta against a tutorial like this since Destron's PHP tutorial.
 
J

joshua huxley

Guest
Your code didn't start with physics in mind, don't use physics_apply_impulse() now. Stop the nonsense and use traditional movement variables.

If you don't have any custom movement variables, set hspeed and vspeed instead of applying an impulse.
Code:
var xkb = lengthdir_x(knockback, dir);
var ykb = lengthdir_y(knockback, dir);
with (other)
{
  //happens inside enemy
  hspeed = xkb;
  vspeed = ykb;
}
If you have custom movement variables like the kind Spalding demonstrates on his tutorials, swap hspeed and vspeed for the equivalent in your code.

And as Jezla said, if you're watching HeartBeast's RPG tutorial right now, STOP! Save the physics system for when you are dealing with realistic physics like those found in Angry Birds or Bad Piggies. And even then, don't use it the way he did.


Damn, if only HeartBeast could see the mess he has made on the GMC and listen to responders like you and I. Not only is his use of physics in that tutorial unsuitable for beginners, his constant brand of abuse of phy_position_x and phy_position_y is unsuitable for just about anyone.

I am beyond sick of cleaning up after HeartBeast's educational malpractice around here. He is the sole reason why novices from the past year can't stop mixing up the traditional movement variables with physics variables. I have not had a vendetta against a tutorial like this since Destron's PHP tutorial.
thank you, could you please recommend an good rpg tutorials that I could use?
 

Jezla

Member
There are many Rpg tutorials out there, Heartbeast even had an older one that used traditional movement and collisions. Just search "gamemaker rpg," and you'll find a ton. Just be cautious; if you see physics, move on to the next one. Rather than simply copying the code, take the author's instructions with a grain of salt and look up each function in the manual to make sure you understand what it does.

If you don't know how to read the error messages that GMS throws at you, then start with basic tutorials that help you understand the IDE.
 
J

joshua huxley

Guest
There are many Rpg tutorials out there, Heartbeast even had an older one that used traditional movement and collisions. Just search "gamemaker rpg," and you'll find a ton. Just be cautious; if you see physics, move on to the next one. Rather than simply copying the code, take the author's instructions with a grain of salt and look up each function in the manual to make sure you understand what it does.

If you don't know how to read the error messages that GMS throws at you, then start with basic tutorials that help you understand the IDE.
ok, thank you very much
 
Top