SGD300 - week 4 Devlog
Introduction
This weeks devlogs is about my attempt to create a simple pickup script tat will at the moment delete an item when the mouse hhas been clicked. I believe the hardest part will be getting the game to know when the button has been clicked and knowing when to pickup the item or if it is supposed to move.
Goals
1. Create a Pickup Script
2. Added the input into the Plyer Controller script.
3. getting the script to move when the item isn't clicked and to pickup an item when the user clicks on an item.
Personnel
Primary - Nathaniel Hughes
Technologies, Tools, and Resources used
Provide resource information for team members who wish to learn additional information from this log.
* [Pickup Example One](https://www.youtube.com/watch?v=yFKg8qVclBk)
*[Destroy on click example](https://www.youtube.com/watch?v=2tkNfsYlENs)
*[Null point exception fix](https://www.youtube.com/watch?v=UYziBhvVIcs)
*[Raycasts Unity](https://docs.unity3d.com/ScriptReference/Physics.Raycast.html)
Tasks Undertaken
1. Research how to pick up items in UNity using C#
2.Create a script to allow for the player to pickup items
3. Add the input into the player controller to allow the user to click the input allow the item to be picked up
4. Make a script that can be added to items that provides information that, a particular item can be picked up.
What we found out
I found out creating a script is far harder than i could imagine, I have looked at many tutorials and other examples and hav found no help in making my task successful. This task can be broken down into three stages, the first was creating the pickup script, the scond was removing the input out of the pick up script and into the player controller and lastly was figuring out how to make everything work. I have run into several issues, the first is making the player controller talk to the pickup script which was throwing a null point exception because the pickup script wasn't attached to the player.
The pick up script consisted of one global variable called pickUpAllowed which was used in the OnTriggerEnter and OnTriggerExit to let the object know it can be picked up. There was a method called pickup that will eventually take an item and added it into the inventory but at the moment it just destroys the object because there is no inventory to add it into as of this moment.
The pick up method in the pick up script has been changed to work with a new method shown to me by a classmate. The method now takes a game object that was saved from the raycasts used in the Character Motor script. This game object will allow us to know what was clicked and if it can be collected.
Solution Justification
Having the character able to collect items is an important mechanic in the game, the pickup script will handle the implementation of this mechanic and will work with the inventory UI that has been created to manage the items in the game and it will work with the player inouts script. The input script will be where the user will be able to interact as the player and collect the items as they are found,
Get SGD300
SGD300
Dev Logs for SGD300 Project
More posts
- SGD300 - Week 13 DevlogOct 24, 2019
- SGD300 - Week 12 DevlogOct 24, 2019
- SGD300 - Week 11 DevlogOct 13, 2019
- SGD300 - week 10 DevlogSep 29, 2019
- SGD300 - week 9 DevlogSep 22, 2019
- SGD300 - week 8 DevlogSep 14, 2019
- SGD300 - week 7 DevlogSep 05, 2019
- SGD300 - week 6 DevlogAug 29, 2019
- SGD300 - week 5 DevlogAug 22, 2019
Leave a comment
Log in with itch.io to leave a comment.