Exye
TIGBaby
|
|
« on: August 05, 2024, 03:21:25 PM » |
|
I've been looking for an answer to this, I keep finding super complicated solutions that don't do what I want. My thoughts are this should be simpler than what I'm finding, or maybe I don't know the best syntax for researching (Google, Stack, GPT)
I want the aircraft to fly like a drone. So the left stick would move forward, backward, left and right (headless) however the craft is angled.
The right stick would turn the craft (image_angle). This is what I have so far, I'm newish to programming and completely new to Gamemaker. Where I'm stuck is finding a way to move the craft side to side with the left stick. I thought motion_add(image_angle -.45), like motion_add/image_angle moves the craft forwards and backwards using pos and neg values but to move it left would be a percent or fraction of the image_angle. I think I'm making sense.
var gamepad_index = 0; var acc_ship = gamepad_axis_value(gamepad_index, gp_axislv); var acc_ship_side = gamepad_axis_value (gamepad_index, gp_axislh); var turn_ship = gamepad_axis_value(gamepad_index, gp_axisrh);
// Headless movement with Left Stick (only forwards and backwards(clarification for the purpose of this post)) if (acc_ship < -0.1){ motion_add(image_angle, 0.1); }
if (acc_ship > 0.1){ motion_add(image_angle, -0.1); }
//Again for the purpose of this post I was thinking, the .45 being 45 degrees less than the actual image angle, how would I write that, or express that idea. Do I need to totally map the craft differently to begin with?
if (acc_ship_side > 0.1{ motion_add(image_angle - .45, 0.1); }
// Turning Ship with Right Stick
if (turn_ship < -0.1){ image_angle += 4; }
if (turn_ship > 0.1){ image_angle -=4; }
Thank you for your time, I've been wrestling with this for days trying to figure it out on my own. I've done a handful of tutorials trying to grasp the basics. I studied a book on C on my own to learn programming principles, finished the Odin Project and CS50 and did a few small projects before starting game dev with gamemaker, for context.
|