J
Josh Perkey
Guest
I'm creating a game where you control a fisherman and his boat. The boat is controlled with the left stick and the player movement and casting is controlled with the right stick. I'd like my character to be able to move around within the boat while also piloting the boat around the water. I'm having an issue with controlling the relative location of the fisher character inside of the boat. The following code is from my boat object. My approach is to update the relative location of the player within the boat whenever the boat is rotated. The code I have currently is working very strangely in that it's keeping the character within the boat as it is rotated, however, it isn't placing the character at the same exact relative location as I intended. Basically, the character is being rotated to the correct angle so it's in the boat, however if the character is off to the side, he is then rotated to the If you don't mind, please take a look at my code and let me know if you have any ideas of what's going wrong here! Thanks in advance!
key_lstickx = gamepad_axis_value(oFisher.controller, gp_axislh);
key_lsticky = gamepad_axis_value(oFisher.controller, gp_axislv);
if (abs(key_lstickx) || abs(key_lsticky)) var move = true; else move = false;
ldirection = direction; // Last direction
direction = point_direction(0, 0, key_lstickx, key_lsticky); // Direction from left stick for boat control
if (move) {
image_angle = direction - 180;
if (ldirection != direction) { // Check to see if the direction has changed since last frame
r = point_distance(x, y, oFisher.x, oFisher.y);
oFisher.x = x + (r*dcos(image_angle)); // option 2
oFisher.y = y - (r*dsin(image_angle)); // option 2;
}
}
hsp = (key_lstickx * bspeed) - xcurrent;
vsp = (key_lsticky * bspeed) - ycurrent;
x += hsp;
y += vsp;
oFisher.x += hsp;
oFisher.y += vsp;
key_lstickx = gamepad_axis_value(oFisher.controller, gp_axislh);
key_lsticky = gamepad_axis_value(oFisher.controller, gp_axislv);
if (abs(key_lstickx) || abs(key_lsticky)) var move = true; else move = false;
ldirection = direction; // Last direction
direction = point_direction(0, 0, key_lstickx, key_lsticky); // Direction from left stick for boat control
if (move) {
image_angle = direction - 180;
if (ldirection != direction) { // Check to see if the direction has changed since last frame
r = point_distance(x, y, oFisher.x, oFisher.y);
oFisher.x = x + (r*dcos(image_angle)); // option 2
oFisher.y = y - (r*dsin(image_angle)); // option 2;
}
}
hsp = (key_lstickx * bspeed) - xcurrent;
vsp = (key_lsticky * bspeed) - ycurrent;
x += hsp;
y += vsp;
oFisher.x += hsp;
oFisher.y += vsp;