• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker How would I make a POV controlled by mouse?

A

Alexthom

Guest
I want to have something where either it just moves to the next wall of a room when the mouse touches left or right of the screen, or make a thing where it just moves when you move the mouse like a POV game. How would I do this?
Thanks!
 

samspade

Member
Many different ways. You probably want to start by watching some tutorials on GMS 2 camera in general. I'd start with this: GMS2 Cameras: As Simple as Possible.

Here are a couple options:
  • set the camera to follow an object and give the object code to do what you want
  • define certain positions in a room and have the camera move between positions when a key or button is pressed
  • set the camera to follow the mouse directly
 
C

Cofefe

Guest
So in GMS2, what you can do is create an object, you can call it obj_view or whatever you want, and you place it in the room. Then in the room editor, in the properties tab under 'viewports and cameras', enable viewports. Then simply choose a viewport, they are labelled 0-7, set it as visible, and then choose obj_view for 'object following'.

Then all you need to do is program obj_view to move the way you want it to and the view will follow it. If you wanted it to move to the left or right of the screen based on where you clicked you could do something like this in the mouse click event:
Code:
if(x < mouse_x) x = //wherever the right side of yours screen is
else x = //wherever the left side of your screen is
And for a very ugly and basic mouse following code, you could place this in the step event:
Code:
x += sign(mouse_x - x);
y += sign(mouse_y - y);
You can tweak that a little bit to make it less ugly as well as faster and more responsive if you want. Like I said very ugly.
 
A

Alexthom

Guest
So for now I was just trying to use keys to make it work...and I tried it before adding textures to all the rooms and it worked..but after adding the objects to make the rooms look good it just gives a black screen...unless I press x to look at the back of the room.
https://imgur.com/a/iVQ1Sxo
 
C

Cofefe

Guest
So you're saying that adding objects to the room makes the screen go black? Unless you are looking at the back of the room...?

I'm not really sure what you mean by back of the room, lol. May we see some of your code? That might shed some light on the situation.
 
A

Alexthom

Guest
And I made it so that when you would press the w a x d keys, you’d look at all four walls, and s looked down. Each wall is just black except for the back wall, or the x key.
(W-front,A-left,X-back,D-right,S-down)
 

samspade

Member
You should review this post. It would help you get better answers to your questions: Posting code on the Programming Forum: Do's and Dont's.

From watching the video, which is a violation of the forum rules, it looks like all of your 'walls' are different room. This is fine, but it means you won't need to do anything with a camera, at least not inherently. And you cannot 'slide' from room to room. Room transitions are instant.

If you wanted a 'slide' effect e.g. Myst combined with fully separate rooms, you would need to take a screenshot (likely by using a surface), switch rooms, place the screenshot next to the room, then slide the camera from the screenshot to the room. That is only a very high level overview of the steps you would need.

I might take a brief step back and review some of the basics of how the GMS 2 IDE works. That would help with asking questions on the forum. Something like this is pretty short but covers the basics fairly well: https://www.youtube.com/playlist?list=PLhIbBGhnxj5I8HuwoNhjgjDC8OQIf8D3Z.
 
Top