Physics Room/Object Bullet

  • Thread starter MeanLikeCharlieSheen
  • Start date
M

MeanLikeCharlieSheen

Guest
Hey was wondering if anyone could shine some light on or point me in the right direction


Trying to create a auto sentry, so i have the sentry working and rotating towards the closest enemy but i'm unable to get the bullet moving without apply_impulse (after playing around with apply_impulse for a few hours i'm still unable to reduce the speed of the bullet even with friction/other physic settings like phy_bullet, the impulse is strong in this one

back to this now after trying to disable physics on the bullet object

GML:
if (instance_exists (obj_enemy_parent)){
    move_towards_point(obj_enemy_parent.x, obj_enemy_parent.y,2)
}

I'm having a play around with the physics engine cause i've never played around with it, got my character moving and everything fine
p.s please don't criticize me i 'WAS' having fun in my own little world :)
 

Tyg

Member
I think its great your using the Physics engine
But objects behave differently
edit your object, on its physics tab you can set all kinds of wonderful things like friction, angular dampening and such
make sure it has uses physics checked :)

when you use impulse you can also clamp it, for example a pool cue hitting a ball, you want an impulse hit
but you want it controlled to the distance back the pool cue was,
i also have a rocketman that uses impulse to blast his jetpack

the impulse isnt applied until the shot strength is determined
the shot strength is determined by the distance the cue has been pulled back

----------------------------------------
physics_apply_impulse(x, y, (x-mouse_x)*Shot_Power, (y-mouse_y)*Shot_Power); // This is where the impulse is applied
---------------------------

So if you want a bullet you want to know a few things like if your going to use different guns you may want a different force applied
Theese can be edited on the bullet object
If the bullets are different grades you want to change gravity and friction that affect it
but after that they all behave the same they either hit there target or disappear or drop
So when you apply an impulse, use a variable in the 3rd and 4th parameter to determine the impulse
or it is always going to fire at a static rate
once fired it bullets physics to slow down
you can also use, say wings off a lampost, then slow the bullet down some and deflect it :)
 
Last edited:
M

MeanLikeCharlieSheen

Guest
Managed to figure it out, if anyone else is new and having the same issue i fixed it (Most likely a very bad way of doing so but it works):

GML:
    //(obj_bullet) Create Event
    parent = instance_nearest(x, y, obj_enemy_parent);
    direction = point_direction(x,y,parent.x,parent.y);
    image_angle = point_direction(x, y, parent.x, parent.y);

    //(obj_bullet) Step Event
    if(distance_to_object(parent) <=126){
        phy_linear_velocity_x=lengthdir_x(25,direction);
        phy_linear_velocity_y=lengthdir_y(25,direction);
    }else{instance_destroy();}
Thank-you for response Tyg <3
 
Last edited by a moderator:
  • Like
Reactions: Tyg
Top