Tuesday, 10 December 2013

Pick up and Throw test.

I have recently been working on getting a pick up object script and a throw script to work for our light orbs. To test out the necessary scripts and such I created a new Unity Project, just incase I ran in to any major problems, I did not want it to mess up our main Unity file. I also wanted to go in depth with this test to prove to myself that I am capable of doing things such as this! so that I will not have to rely on Playmaker.



In the first screen shot, I have done it so you can see the basic test scene that I have created. Over on the right hand side you can see the three scripts that I have used, the first one is the Object Properties script, which is in C#, this script is attached to the object that you want to pick up. For this script to work, the object needed a collider so that the character controller could be able to pick it up, it also needed a rigid body component added to it. The next script is another C# script, this is attached to the character controller which enables it to be able to pick up the object when the player presses the 'f' key, as well as being able to throw the object when the player clicks the left mouse button. The final script is Javascript, this is also on the character controller, and this controls the power in which the object is thrown by the character. I still need to tweak the power in which the object is being thrown, because at the moment it is too powerful.

The bottom screenshot shows the character controller holding the object (I could not print screen the throw action because it disappeared before I could!!).

No comments:

Post a Comment