Follow mouse with actor on extended scene?

johnnyk022181

  • Posts: 96
I am putting an actor on a scene which I extended.  I am trying to use the "Follow Mouse" behavior on the actor.  It works fine until I move further on the scene then it just starts to get left behind and doesn't drag all the way to the end of the scene.  How can I make the actor keep up with the mouse cursor?

kynbo

  • Posts: 139
Can you post a screenshot of what it looks like when your actor is left behind?
Do you have a behavior that move your camera on the "extended scene"? If not you need to find or make one that moves your camera.

johnnyk022181

  • Posts: 96
The first two pictures is of the Scene and it's Properties.  The other pictures are of the Actors Behavior and Events. 

kynbo

  • Posts: 139
- I added X and Y of camera to X and Y of mouse so that the actor wouldn't just move to the mouse positions (X and Y mouse positions are position of the screen, not the scene)

- Check: if mouse location is smaller or greater than half of the screen's height, then move camera's Y position to a new Y position (default of camera speed is 2; change it if you want)

johnnyk022181

  • Posts: 96
Thank you for responding.  The code is scrolling automatically and doesn't give me any control to move up or down with the mouse. 

kynbo

  • Posts: 139
How do you want the camera to move up and down with the mouse exactly? By pressing up and down keys? Or when the mouse is close the the edge of the screen?

johnnyk022181

  • Posts: 96
It would be nice if the scene could follow the mouse cursor.  This will eventually be a mobile game, so swiping the Menu Scene up and down  will be very important.

kynbo

  • Posts: 139
I don't have any experience with designing a mobile game. But I think you can just remove the "if" and "otherwise if" blocks and put in "Move camera to [self]" block. Also, if you want to control if the scene would move or not, then check if "mouse is down"

johnnyk022181

  • Posts: 96
IT WORKED!!!  Thank you very much!!  Have an awesome weekend!!

johnnyk022181

  • Posts: 96
One very last thing.. How can I make it so it scrolls slower?

kynbo

  • Posts: 139
Find and download "Camera Follow" by Rcoinb in StencylForge.
Remove "if mouse is down" block in your own behavior
Add the "if mouse is down" block to the Always event in the "Camera Follow" behavior (the new behavior you just downloaded) and drag everything in that event under the "if mouse is down" block.
Attach the new behavior to your actor and adjust the scroll speed

johnnyk022181

  • Posts: 96
I couldn't get it to work properly by just adding the Camera Follow  Behavior and following the steps.  I also added the Smooth Camera Behavior along side your instructions and it now works perfectly.  Again, thank you so much for helping me. 

johnnyk022181

  • Posts: 96
It's still very glitchy.  Maybe it will be easier to just put an Up and Down button on the screen which are Anchored.  How can I make that work?  For example: The screen moves depending on if your pressing down on the Up or Down buttons.  Once you let go of the button, it stops moving the scene.