A
AwesomeAlvin
Guest
So, i've been confused about as to why these different sets of code works different than each other.
So to set up the scene, it's a top down shooter using the physics engine, and I'm confused about the shooting mechanics. One of them works, one of them doesn't.
The one that works:
So the above code is in the gun object which creates the bullet. The bullet has a parent object and in the create event uses event_inherited(); and also has it's own projectileSpeed.
This is what it looks like in the parent object.
Now, this code works perfectly, but when I try to have the bullet control the impulse instead of the gun, it doesn't seem to work.
So the one that doesn't work, is pretty much the impulse code cut and pasted into the parent object.
When I shoot with this one, then the bullets only travel to the left, and not where I'm pointing.
The direct variable is just the direction of the mouse.
So how come the shooting only works properly when the impulse is controlled by the gun?
Any help would be appreciated, thanks!
So to set up the scene, it's a top down shooter using the physics engine, and I'm confused about the shooting mechanics. One of them works, one of them doesn't.
The one that works:
Code:
bullet = instance_create(x, y, obj_pistol_bullet)
with (bullet) {
bulletDirection = other.direct;
physics_apply_impulse(x, y, lengthdir_x(projectileSpeed, bulletDirection), lengthdir_y(projectileSpeed, bulletDirection));
}
This is what it looks like in the parent object.
Code:
bulletDirection = noone;
projectileSpeed = noone;
So the one that doesn't work, is pretty much the impulse code cut and pasted into the parent object.
When I shoot with this one, then the bullets only travel to the left, and not where I'm pointing.
The direct variable is just the direction of the mouse.
So how come the shooting only works properly when the impulse is controlled by the gun?
Any help would be appreciated, thanks!