Hi all, I’m wondering if you could help me with a small issue I’m having.
I’m developing a sailing game for a project in College. It’s going to be a game for the Android, eventually, but for now, I’m just developing it with PC controls for convenience. Trying to simulate a touch and swipe with the mouse is my current issue.
Basically, my boat’s going to have broadside cannons, but the camera is fixed meaning that the boat’s rotation is independent from the camera, so the direction of the swipe will determine which side the cannons are fired out of. That part is figured out though, I have a good idea on what I’m doing for that. My current problem is the actual inputs themselves.
When I click my mouse, it’s in a fixed location, which could skew the direction result, I want it to update with my sailboat’s movement, I also want to draw an arrow from the clicked position (in screen coordinates), to where the mouse currently is (in screen coordinates), but it never appears on screen, in fact, it appears way above the camera.
Does this make sense? I have a feeling I’m not getting my exact problems across.
My code is as follows (in the update function):
// Get if the mouse is clicked and held
if ( Input.GetMouseButtonDown( 0 ) )
{
_mouseClickPosition = Input.mousePosition + gameObject.transform.position;
_isDragging = true;
}
// if you want to input an aiming arrow, do it here
if ( _isDragging )
{
Debug.DrawLine(_mouseClickPosition, Input.mousePosition, Color.white);
}
// mouse released
if ( Input.GetMouseButtonUp( 0 ) && _isDragging )
{
_mouseReleasePosition = Input.mousePosition;
_isDragging = false;
}
Edit
I should probably mention, what I’m aiming for is something like Angry Birds’ slingshot mechanic (though it only depends on the rotation which isn’t limited), except it’ll be moving along with the player.
Edit 2
I utilized my fantastic paint skills to try and get a screenshot of my current problem