T
trentallain
Guest
How do I create a barrel roll animation and rotate the view but not the player for this scenario?
In gms 1.x you could do:
Which would basically rotate the card along the Y axis with the correct 3D perspective (while not requiring anything else 3D).
Atm I have an x-wing that moves at a constant speed and turns using "A" and "D". And also uses sprite stacking to achieve a 3D look, while staying 2D.
Create:
Draw:
Step:
The barrel roll: Needs to have the correct perspective in all directions. (and will rotate around an axis from its nose to rear in the center.)
The rotating view: The player's ship would not be rotated, so that the ship is always facing up. Any other object that uses sprite stacking (such as other ships) will also need to be at the same perspective as the x-wing (A 3/4 or overhead view - same as the x-wing). I have a feeling transformation matrices would be used here so that they are at the correct positions - I'm probably wrong here and it will have nothing to do with it, but I have no experience with them.
Link to a diagram of what I mean with barrel rolling:
https://drive.google.com/open?id=1Po1odmyVzhMR7tsbWv0W-hAWiVK1lExM
Links to the rotating view effect (as well as stacking sprites for a 3D effect):
https://gfycat.com/ConsciousZanyArmedcrab and https://www.reddit.com/r/gamedev/comments/57x7n3/really_cool_fake_3d_in_gamemaker_by_the_creator/
In gms 1.x you could do:
Code:
d3d_transform_set_rotation_y(variable);
d3d_transform_add_translation(x,y,0);
draw_sprite(spr_card,variable_two,0,0);
d3d_transform_set_identity();
Atm I have an x-wing that moves at a constant speed and turns using "A" and "D". And also uses sprite stacking to achieve a 3D look, while staying 2D.
Create:
Code:
image_speed = 0
scale = 4
camera = camera_create_view(0,0,1920,1080,0,-1,-1,-1,0,0)
view_set_camera(0,camera)
scope_length = 200
view_width = camera_get_view_width(camera)
view_height = camera_get_view_height(camera)
view_x = camera_get_view_x(camera)
view_y = camera_get_view_y(camera)
draw_set_font(font0)
angle = 0
Code:
for (var i = 0; i < image_number; i += 1)
{
draw_sprite_ext(sprite_index, i, x, y - i*scale, scale, scale, angle+90, c_white, 1); //The x-wing's sprite is facing up, so I added 90.
}
Code:
speed = 10
angle += -4*sign(keyboard_check(ord("D")) - keyboard_check(ord("A")))
direction = angle
camera_aim_direction = angle
//Aiming
view_x = camera_get_view_x(camera)
view_y = camera_get_view_y(camera)
camera_set_view_pos(camera,x + lengthdir_x(scope_length, camera_aim_direction)-view_width/2,y + lengthdir_y(scope_length, camera_aim_direction)-view_height/2)
The rotating view: The player's ship would not be rotated, so that the ship is always facing up. Any other object that uses sprite stacking (such as other ships) will also need to be at the same perspective as the x-wing (A 3/4 or overhead view - same as the x-wing). I have a feeling transformation matrices would be used here so that they are at the correct positions - I'm probably wrong here and it will have nothing to do with it, but I have no experience with them.
Link to a diagram of what I mean with barrel rolling:
https://drive.google.com/open?id=1Po1odmyVzhMR7tsbWv0W-hAWiVK1lExM
Links to the rotating view effect (as well as stacking sprites for a 3D effect):
https://gfycat.com/ConsciousZanyArmedcrab and https://www.reddit.com/r/gamedev/comments/57x7n3/really_cool_fake_3d_in_gamemaker_by_the_creator/