# [solved]Multi Object rotation

W

#### Wild_West

##### Guest
So I've used this method of rotating objects successfully before but that was only with 1 object.
If I try to use this with more than 1 they rotate in the same place all mashed together.
How would I go about making multiple objects rotate around one object but stay away from eachother in a fixed location.

Code:
//Making Bullets Rotate around self
bomb_1_id.x = x + lengthdir_x(140,0);
bomb_1_id.y = y + lengthdir_y(140,0);

bomb_2_id.x = x + lengthdir_x(140,90);
bomb_2_id.y = y + lengthdir_y(140,90);

bomb_3_id.x = x + lengthdir_x(140,180);
bomb_3_id.y = y + lengthdir_y(140,180);

bomb_4_id.x = x + lengthdir_x(140,270);
bomb_4_id.y = y + lengthdir_y(140,270);
In this object's create event it makes the 4 bombs and tags them all with bomb_number_id.

#### NazGhuL

##### NazTaiL
Hi!
You first need to access all the bombs id. On a list, on an array... I'll use array;
Code:
//Create Event
rotation = 0;
array_bomb = 0;

var count = 0;
repeat(4)
{
array_bomb[count] = instance_create(x, y ,obj_bomb);
count++;
}

//Step Event

var qty = array_length_1d(array_bomb);
var deg_dif = round(360/qty);
var count = 0;
var tmp_bomb;
var tx = target.x;//the point you want them to turn around
var ty = target.y;
var len = 64;//The distance from the point
var r = rotation;

repeat(qty)
{
tmp_bomb = array_bomb[count];

with(tmp_bomb)
{
x = tx + lengthdir_x(r+count*deg_dif, len);
y = ty + lengthdir_y(r+count*deg_dif, len);
}

count++;
}

rotation = (rotation+1) mod 360;
didn't test it, but i'm pretty sure it works good.
-edit-
changed list for array.

Last edited:
W

#### Wild_West

##### Guest
Hi!
You first need to access all the bombs id. On a list, on an array... I'll use array;
Code:
//Create Event
rotation = 0;
array_bomb = 0;

var count = 0;
repeat(4)
{
array_bomb[count] = instance_create(x, y ,obj_bomb);
count++;
}

//Step Event

var qty = array_length_1d(array_bomb);
var deg_dif = round(360/qty);
var count = 0;
var tmp_bomb;
var tx = target.x;//the point you want them to turn around
var ty = target.y;
var len = 64;//The distance from the point
var r = rotation;

repeat(qty)
{
tmp_bomb = array_bomb[count];

with(tmp_bomb)
{
x = tx + lengthdir_x(r+count*deg_dif, len);
y = ty + lengthdir_y(r+count*deg_dif, len);
}

count++;
}

rotation = (rotation+1) mod 360;
didn't test it, but i'm pretty sure it works good.
-edit-
changed list for array.
Okay well the answer was actually way simpler than all that.
Just had to use the object's direction not the one they were rotating around, duh. But thanks anyway.

Code:
//Making Bullets Rotate around self
bomb_1.direction += 10;
bomb_1_id.x = x + lengthdir_x(140,0+bomb_1.direction);
bomb_1_id.y = y + lengthdir_y(140,0+bomb_1.direction);

bomb_2.direction += 10;
bomb_2_id.x = x + lengthdir_x(140,90+bomb_2.direction);
bomb_2_id.y = y + lengthdir_y(140,90+bomb_2.direction);

bomb_3.direction += 10;
bomb_3_id.x = x + lengthdir_x(140,180+bomb_3.direction);
bomb_3_id.y = y + lengthdir_y(140,180+bomb_3.direction);

bomb_4.direction += 10;
bomb_4_id.x = x + lengthdir_x(140,270+bomb_4.direction);
bomb_4_id.y = y + lengthdir_y(140,270+bomb_4.direction);