PlaceholderGames / 2122-yr1-team-cookieshot

CS1S464 2021/22 Team Cookieshot
0 stars 0 forks source link

Adding mouse input and removing the player character #4

Closed DoctorMikeReddy closed 2 years ago

DoctorMikeReddy commented 2 years ago

After discussions yesterday, Monday 18th, it is clear that the game needs mouse input, a la the original Lemmings, and the player character removed. I will make a branch off main to do this.

DoctorMikeReddy commented 2 years ago

NOTE: screen shots are from another game, but are similar to those I have uploaded to the repo, in branch "mouse".

Firstly, we need to create an InputAction in Edit-> Project Settings -> Engine-> Input: AddingMouseControls This creates an Event Action Blueprint that can be used in the 2D side scroller controller. We are going to use this initially to just print text to the screen during play; it will not distinguish between left or right buttons yet: BP_example but running the game and clicking the mouse buttons now works: sampleBP_effect Making the mouse pointer show while playing - normally, it disappears after you click in the run window - by altering the player controller BP: enable_mouse Normally, this would be done in a menu blueprint, but as it is part of the game, I have added it to the player controller for convenience. [No point showing a screen shot, as Windows removes the mouse anyway; trust me, this works now]

Pushed to branch "mouse". Next is finding a way to distinguish between left and right mouse buttons. And removing the player character. Some useful resources:

https://www.youtube.com/watch?v=KakLXqpwnjo - a tutorial for adding clickable objects in a 3D game, so not so relevant to what we want, but showing the mouse events was useful, even if it was out of date

https://answers.unrealengine.com/questions/367303/how-to-create-an-object-on-mouse-click-from-a-choi.html

https://www.worldofleveldesign.com/categories/ue4/ue4-getting-started-crash-course.php

DoctorMikeReddy commented 2 years ago

A better static camera, with material adapted from here: https://romeroblueprints.blogspot.com/2015/06/paper-2d-game-sprites-and-camera.html

DoctorMikeReddy commented 2 years ago

Replaced the player character with a mouse mode player controller. Based these changes on the following tutorial: https://docs.unrealengine.com/4.27/en-US/Resources/ContentExamples/MouseInterface/MouseControlSetup/ Removed all the previous player controller blueprints. Again in the mouse branch. Enjoy.

DoctorMikeReddy commented 2 years ago

Say here if you need any further help. When you are happy, we can merge this into the main. You will have to add the AI spawner, etc, from the other branch, lemming, at your own pace. Mouse currently does nothing, so you will need to add code to the MouseController class

DoctorMikeReddy commented 2 years ago

These videos might be of use: https://www.youtube.com/watch?v=PdX5HJz8Z5U https://www.youtube.com/watch?v=qdlF5KI83WY This tutorial might also be useful: https://medium.com/@willsaunders_73724/context-sensitive-mouse-cursor-tutorial-for-unreal-engine-4-69ccd6261cc