Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Thursday, 16 May 2013

GUI - Sound toggle and exit button

I have added sound to the project, and I have created button functionality whereby the user can toggle sound on and off, and also exit the Unity application to go back to the home screen. I think sound makes the project more interactive and immersive. The button functionality involved more JavaScript code, which the Unity Community is very useful for. With a lot of this kind of functionality, it's considered quite basic so a lot of people have already done it, and it's not too hard to find examples online.



This one was useful for the on/off button:

http://answers.unity3d.com/questions/303807/music-onoff-switch.html

The exit button really only required the use of the Application.LoadLevel command.

Unity embedded!

I finally succeeded in embedding the web player with suitable dimensions. I decided to use the web page generated by Unity in the build stage and adding my home page elements, rather than attempting to get the player into my already-created homepage, and it works much better. Now all I really need to do is get the cursor constrained to the centre of the application and it has all the functionality I need it to have. Exciting times!

 

Wednesday, 15 May 2013

Application.OpenURL vs Application.ExternalEval

To address one of the problems mentioned in the previous post, the fact that Application.OpenURL only opens the website in the current browser window rather than in a new tab, I did some research on the Unity Community forums and found the using Application.ExternalEval will actually open the page in a new tab, so it is less disruptive to the enjoyment of the viewer. Here is the code I used:

 function OnMouseUp()
    {
    Application.ExternalEval("window.open('http://www.youtube.com','YouTube')");
    }

And the code I replaced:

 function OnMouseUp()
{
    Application.OpenURL('http://www.youtube.com');
}

I still haven't attached it to my own website though. That will be next.

Note: Since originally creating this post, I have added functionality allowing for a page of the project to be opened rather than YouTube, calling the file from my folder structure like so:

 Application.ExternalEval("window.open('../../K00123456_Project_2013/macehead.html','Macehead')");

Splash Screen and web embedding

I created a basic splash screen and loaded the game to playing on clicking the button. It looks dreadful but at least I have the functionality there; I will edit it later.

The problem with the stretched application continues; I have uploaded to the web page but it stretches across the entire browser and does not look good. The code I used is available here:

http://docs.unity3d.com/Documentation/Manual/WorkingwithUnityObject.html#initPlugin 

I have posted on the Unity forums to find out if anyone can help, as I can't figure it out. Hopefully that will show something up. 

Another issue is that, in the finished application, when you click on an object to open a web page, it doesn't open in a new tab, rather it opens in the tab you have open so you have to browse back to the application and restart it. This is a pretty big problem so I am looking into ways to fix this now.

This is how much the application stretches :(
 

Tuesday, 14 May 2013

First Person Controller and terrain constraints

My terrain is essentially finished, I might add some trees and grass later on but at the moment it is the shape I want it to be, apart from one small problem: I can't currently prevent my first person controller from going into the lake and not being able to get out. I have used step offset and slope limit to prevent him from going up the hills, but unfortunately I'm not sure how this works in the opposite direction. I've tried smoothing out the terrain by raising the parts of the lake that I've lowered, and it may just end up being a tedious process of doing that, but I'm sure there is also a scripting method I can use so I have to find that out.


This is what you can see from the lake. But you can't really do anything!

Friday, 3 May 2013

PHP assignment - useful for the project


Yesterday I handed up  30% assignment for the Advanced Web Programming class that I think will be very beneficial to the project. The task was to create a database with full CRUD functionality in order to make a static website dynamic. Below is an example of the 'read' code and the resulting web page. 



It was quite a difficult project and not all of it works, but hopefully I will be able to iron out the problems to achieve full functionality within the project itself.