• 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 Bullets wrong location

S

Stephen

Guest
I took the screenshot with as much info as I could and also what happens when I go to shoot. I was able to get my gun to follow my mouse but when I fire, it fires from the position the first sprite image is set to, which I was told had to be backwards. I would like to have the bullets leave the gun in the direction it is facing.
I did attempt to find how to, but almost all the tutorials out there are of a completely different style of gamemaker.
I uploaded the photo from photobucket.
http://s268.photobucket.com/user/smarcum28/media/firstissue.png.html
 

TheouAegis

Member
instance_create( x + a * image_xscale, y + b, obj_bullet)

Replace a and b with the offsets you need.


That image is too tiny on my screen. You should click Show Information in the player object and copy/paste all the info in it so people can actually see what you're doing.
 
S

Stephen

Guest
Information about object: obj_weapon01
Sprite: spr_weapon01
Solid: false
Visible: true
Depth: -5
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Step Event:
start moving in the direction of position (mouse_x,mouse_y) with speed 0
set the sprite to spr_weapon01 with subimage direction and speed 0
Mouse Event for Glob Left Button:
create instance of object obj_bullet01 at relative position (0,0)

My player obj doesnt move or spawn anything. I am drawing his arms/hands holding each type of weapon.
 

TheouAegis

Member
It should be leaving from wherever the gun/arm's sprite's origin is at in the room. Put in the Draw Event of the gun/arm:

draw_self();
draw_set_color(c_red)
draw_rectangle(x-1,y-1,x+2,y+2,0);
draw_set_color(c_black);

See where the rectangle is being drawn.
 
C

CROmartin

Guest
Put in bullet creat event "move_towards_point( mouse_x, mouse_y, speed )"
 
S

Stephen

Guest
Ok, my obj_weapon on the rooms I hate to have it facing the opposite direction to get it to turn at the pivot point, the guys shoulder. So I did this:
event Step, Move towards point(mouse_x,mouse_y) and also Change sprite into spr_weapon
Now do I need to have obj_weapon to on global left click create a obj_bullet and then edit obj_bullet to event step, move towards point?
 
S

Stephen

Guest
On my obj_weapon I am now using this
bullet = instance_create(x,y,obj_bullet01);

bullet.direction = image_angle;
bullet.image_angle = image_angle;
bullet.speed = 12;

But it looks like my obj_weapon is aiming at the mouse location but the bullets are still only going in the one direction from where I placed it in the rm_level
 

TheouAegis

Member
Does your gun actually use image_angle or do you have multiple subimages in the sprite to point it in the correct direction?

Post all the code inside obj_weapon.
 
S

Stephen

Guest
Information about object: obj_weapon01
Sprite: spr_weapon01
Solid: false
Visible: true
Depth: -5
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Step Event:
execute code:

image_angle = point_direction(x, y, mouse_x, mouse_y);

Mouse Event for Glob Left Button:
execute code:

bullet = instance_create(x,y,obj_bullet01);

bullet.direction = image_angle;
bullet.image_angle = image_angle;
bullet.speed = 12;
 
S

Stephen

Guest
The bullets create at the point I told it was center, which was the shoulder to give it a 360 degree windmill aiming ability
 
S

Stephen

Guest
The only thing my bullet has is a parent that basicly off screen = delete
 

TheouAegis

Member
Do you have any code anywhere in any object that affects either obj_bullet01 or its parent? Search your entire project for any and all references to bullets. I mean, you handle the bullet properly here, but maybe you have leftover code from earlier that you handled bullets improperly and you're setting the speed of all bullets.

Also, make sure you didn't parent the parent. You can have grandparents in GM.

Your bullet code here should be fine, so the issue would be outside the gun. Something is overriding the speed and direction variables.
 
S

Stephen

Guest
I went back over my properties and watched a few more youtube videos, am I suppose to be telling obj_weapon where to spawn obj_bullet01? All the codes I have in for it only control the direction and speed.
(side note: why does everyones program look different than the one I use, which is Professional Edition 1.4.1763?)
 
C

Carbiner

Guest
You are missing this one very vital step:
inst.direction = point_direction(x,y,mouse_x,mouse_y);
slam that next to your image angle and speed code and it should work just fine.
You are telling the bullets to point at the mouse, but not to move at the mouse.
As for the program difference, its between studio, which is free, and professional, which is not.
 
C

Carbiner

Guest
Your bullet code here should be fine, so the issue would be outside the gun. Something is overriding the speed and direction variables.
For that bit he said it best.

As the placement of the bullet if the center of your weapon is the shoulder, and not the tip of the gun you need to tell game maker to spawn the bullet at the tip, which will not obj_weapon01.

You need something like this:
Code:
bullet = instance_create(x + lengthdir_x(len1_x,rot) - lengthdir_y(len1_y,image_angle) ,y + lengthdir_y(len1_x,image_angle) + lengthdir_x(len1_y,image_angle) ,obj_bullet01);
len1_x / len1_y are defined in the create event of the weapon. They are x/y difference from center that the tip of the gun is, in the image editor.
Watch this video for a tutorial on this:
 
Top