S
seraph
Guest
Hi community, new to forums and development in GMAKER2
I have an odd rotation problem to do with x and y offsets. When I reference self.x, self.y for my 1 pixel sprite it appears to offset itself with opposite rotation values. Below is the draw line event (a hitscan gun) and below that is where I set my fixtures up with some image references.
I'm using physics angular forces to rotate my player object, my assumption is that self.x, self.y are normalized to my objects rotation and should therefore follow when the object is rotated, but, instead I get some offsets as shown below. (lists are counterclockwise rotation 90 degree steps).
Not sure if that's clear enough but would love help, been puzzling over this for a week now (to clarify, the spawn point of my drawnline is offsetting itself by values and images shown below. The same happens for spawning objects and such.)
X offset
90 degrees counter clockwise rotation.
I have an odd rotation problem to do with x and y offsets. When I reference self.x, self.y for my 1 pixel sprite it appears to offset itself with opposite rotation values. Below is the draw line event (a hitscan gun) and below that is where I set my fixtures up with some image references.
I'm using physics angular forces to rotate my player object, my assumption is that self.x, self.y are normalized to my objects rotation and should therefore follow when the object is rotated, but, instead I get some offsets as shown below. (lists are counterclockwise rotation 90 degree steps).
Not sure if that's clear enough but would love help, been puzzling over this for a week now (to clarify, the spawn point of my drawnline is offsetting itself by values and images shown below. The same happens for spawning objects and such.)
X offset
- 0
- 0
- 1
- 1
- 0
- 2
- 2
- 0
90 degrees counter clockwise rotation.
if mouse_check_button(mb_left) {
//Variables
var allowed_coll_layer = self.layer
var force_originx = self.x
var force_originy = self.y
var dir = point_direction(x, y, mouse_x, mouse_y); //connect a line between origin and the mouse
//show_debug_message(mouse_x)
var d = 400; //the maximum number of pixels from origin to endpoint that the laser can extend
var spread = random_range(-0,0); //(optional) randomly offset the angle of the line before it goes out
var shot_distance = 0
var max_shot_distance = 500
while (shot_distance <= max_shot_distance) {
var lx = x + lengthdir_x(shot_distance, dir + spread); //the line will continually check 1 pixel ahead of itself as it extends
var ly = y + lengthdir_y(shot_distance, dir + spread);
var hit = (collision_line(x, y, lx, ly, phys_controller, false, true)); //shorthand for "an object in the way of our collision line")
var static_hit = (collision_line(x, y, lx, ly, static_phys_dummy, false, true)); //shorthand for "an object in the way of our collision line")
if (hit != noone) or (shot_distance == max_shot_distance) {
xx = self.x + lengthdir_x(shot_distance, dir);
yy = self.y + lengthdir_y(shot_distance, dir);
draw_set_colour(c_aqua);
//draw_line((self.x - 1), (self.y - 1), xx, yy);
draw_line((self.x), (self.y), lx, ly);
//determine the sprites dividable width and height and offset our fixture to the
//relative point of mass within that sprite.
if (self.sprite_width % 2 == 0) {
var x_fixture_offset = 0;
} else if (self.sprite_width % 2 == 1) {
var x_fixture_offset = -0.5;
}
if (self.sprite_height % 2 == 0) {
var y_fixture_offset = 0;
} else if (self.sprite_height % 2 == 1) {
var y_fixture_offset = -0.5;
}