And I also need a reference to the current character so I can destroy it before I the new prefab. So I need to be able to access the position of the current character. And I need to do that because when it's time to change to a new character, I want to put the new character where the current character currently is. I also need to keep track of the current character. These are the four fields that we can populate in the Inspector with the pre fabs for each of our characters. Let's go take a look at the character changer script. But we want to make sure that we put that logic at the game level, not inside other lower level objects that really shouldn't know about other objects in the game. We may write other Game Manager scripts as we move along that do much more than changing characters. So it makes sense to attach this game level logic to the main camera. We know the main camera is going to be in every scene that we have in our game. At this point we're putting it in the script that we attached to the main camera. So when we have game level functionality we want to make sure we put it in the appropriate place. It's behavior of the game, not a behavior of a specific character. So it wouldn't make sense to put these functionality inside individual characters because that's not behavior of a character. So changing characters is game level logic not character level logic. And I have populated four fields in that character changer script with our four pre fabs for our four different characters. I've selected the main camera here to show that I've attached that character changer script to the main camera. To support changing characters when the player presses the left mouse button, I've added a character changer script.
Processing pmouse how to#
In this lecture, we'll learn how to process mouse button input in our Unity games. This course is an independent work and is not sponsored by, authorized by, or affiliated with Unity Technologies or its affiliates View SyllabusĪ couple of lectures ago we learned how to retrieve and use mouse position in our Unity Games. “Unity” is a trademark or registered trademark of Unity Technologies or its affiliates in the U.S. Module 4: Learn how we can store lots of data in arrays and lists
Processing pmouse code#
Module 3: Learn how to use iteration (looping) to repeat actions in your code Module 2: Learn how to get and use player input in your Unity games Module 1: Learn how we make decisions in our code
The material in this and the previous course is essentially our first programming course for Game Design and Development majors at UCCS. Throughout this course you'll continue building your foundational C# and Unity knowledge by exploring more C# and Unity topics and finishing the Unity game you started at the end of the previous course. You should make sure you have that knowledge, either by taking that previous course or from personal experience, before tackling this course. This course assumes you have the prerequisite knowledge from the previous course in the specialization. Also, the Unity game engine is very popular with indie game developers Unity games were downloaded 16,000,000,000 times in 2016! Finally, C# is one of the programming languages you can use in the Unity environment. Why use C# and Unity instead of some other language and game engine? Well, C# is a really good language for learning how to program and then programming professionally.
Processing pmouse windows#
This course is the second course in the specialization about learning how to develop video games using the C# programming language and the Unity game engine on Windows or Mac.