Legacy GM [SOLVED]Rotating drawn primitive relative to object

D

Docker

Guest
I'm attempting to create a vision cone for a camera within my game but I've been stuck on this for 4 hours and I'm too stupid to see what I'm doing wrong

Inside the obj_camera object create event I have:
Code:
camera_vision = instance_create(x, y, obj_camera_vision);
camera_vision.creator = id;
Inside my draw event for obj_camera_vision I have:
Code:
draw_primitive_begin(pr_trianglelist);
draw_vertex(x, y);
draw_vertex(x+lengthdir_x(100, creator.image_angle), y+lengthdir_y(100, creator.image_angle-20));
draw_vertex(x+lengthdir_x(100, creator.image_angle), y+lengthdir_y(100, creator.image_angle+20));
draw_primitive_end();
It rotates with the camera object but the vertexes move and warp the shape of the cone, can someone please tell me what I'm misunderstanding? I've been creating and deleting code for 4 hours trying to get my head around this and I'm at the point of having a nervous breakdown...

It performs the shape as intended without obj_camera moving
 
Last edited:
D

Docker

Guest
After all this time I've now figured out it was because I needed +- 20 in the lengthdir_x direction...
 
J

JVGameDev

Guest
How do you make your code proper like that instead of text?
 
Top