GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Player runs in to invisible barrier? [Answered]

mlindenbmlindenb Posts: 4Member, PRO
edited October 2016 in Working with GS (PC)

I'm having an issue where my player actor won't go outside the initial camera area, despite the scene being larger. Its movement is set up so that on mouse press, it rotates to face the mouse position and then go to it. I also have it set to control the camera. Simple enough.
The problem is that when I move the mouse outside that starting area the player will hit some sort of invisible barrier and then just keep circling as it tries to move past it.

What gets weird is that if I set it up to move via key press then it works fine, no barriers, just open access across the scene. I can also make the camera as large as the scene and then the player will follow the mouse position, but its zoomed out.

There has to be a fix for this but I'm coming up blank. Any help would be greatly appreciated!

Comments

  • It looks like the X Y coordinates gamesalad uses for the mouse aren't where they are in the level, but just where they are on the camera. Strange I didn't know it worked that way. I'm sure someone has a math equation that can then determine where the point is on the scene for you.

  • AlchimiaStudiosAlchimiaStudios Posts: 1,041Member, PRO
    edited October 2016

    @mlindenb Yeah mouse position can only be detected within the bound of the screen, make sense because the mouse is always within the screen. This can actually be useful, especially for UI purposes.

    But as you've discovered it has the consequence of not being able to use mouse X and Y for player actor X/Y translation directly.

    But you can use Camera Origins+Mouse pos to determine scene position of a click.

    Camera origin X/Y will always be 0 until the camera moves outside of the original camera pos, then it starts counting. So if you have a scene at 2048=X and 1024=Y, and a camera size of 1024x1024 and an actor moving left to right that has a control camera on it, once the actor passes 1024 scene X or Y the camera origin goes counting up from 0 to 1, 2, etc until the outer edge is reached at 2048 scene (or 1024 camera origin x).

    That means if you click at 2048 on screen, your mouse X is 1024 and your camera origins is 1024, so you have 1024+1024=2048 for an accurate position.

    This is a scene level attribute though, so you'll need to unlock an actor to see it in the dropdown under scene.

    Follow us: Twitter - Website

  • SocksSocks London, UK.Posts: 12,822Member
    edited October 2016

    'Mouse postion' relates to the screen or camera area (what you can see when playing your game), it doesn't relate to your scene, for example mouse coordinates for a 1024 x 768 (iPad) project will only ever return a 1024 x 768 value range, even if your overall scene is 10,000 x 10,000 pixels.

    So if the exact middle of our camera area is 512, 384 (1024/2, 768/2) - and we touch the middle of the screen the mouse coordinates will be 512, 384 . . . . . now let's move the camera to 8000, 8000 . . . now when we touch the middle of the screen our finger/mouse has just touched 8512, 8384 in your scene . . . but as the mouse coordinates refers to the screen/camera area (and not your scene) it will return your touch position as 512, 384.

    If you want mouse coordinates to refer to your scene rather than the screen/camera, then simply add camera position ('camera origin') to the touch, so in the above example just add camera origin x and camera origin y to the touch position, you could also use raw mouse position instead of plain old mouse position, but I've found that although raw mouse works fine in Creator it doesn't always correctly translate to mobile devices, so just to be safe and keep it simple I'd stick with mouse+camera origin.

    "it rotates to face the mouse position"

    When you touch the screen you will always be - using the 1024 x 768 iPad example - returning a value within a 1024 x 768 range.

  • mlindenbmlindenb Posts: 4Member, PRO

    Thank You all for the help! Its working now and you all are amazing.

Sign In or Register to comment.