Redirecting you to bearmacstudios.com.... BearMac Studios: Scripts

Pages

Showing posts with label Scripts. Show all posts
Showing posts with label Scripts. Show all posts

Monday, February 20, 2012

Future Features!

This has been keeping me up all night, so just to get my thoughts down I'm going to write this out.
What I plan to add in the near future:

  • Save System
  • Point System, or Story line?
  • More Puzzle types
  • Rigid body movement?
  • switches and what not
The thing that's been keeping me up has been the save system. I have a sort of Idea of how to tackle this, but here it goes. I'm going to use the playerprefs class to save an integer, this integer will be directly linked to the level completed. So by this method I will be saving only one variable, and in between maps. For instance;

Player clicks "Load Game"> Level Completed variable = 2 > load second level. 
or
Player clicks "Load Game">Level Completed variable = 0 or null > Display message "No Game Started"

My problem is that I don't want a million loading screens for every time in between levels, so I need a variable that won't change in between levels and every time a level is completed it will add one to the Level Completed variable which is saved by the playerprefs class, but I'm getting tired so now my brain is wandering to new problems that didn't exist before, and probably won't exist in the morning. So I say to everyone reading. Goodnight, and also, thanks. ;)

Thursday, February 16, 2012

Pause Menu Script!

Here's a script that's extremely similar to the main menu script. It's for the pause menu in the tutorial that's on YouTube right now!

var menuHeight:float=500;
var menuWidth:float=500;
var buttonSpacing:float=25;
var mainMenu: String = "MainMenu";
var titleTexture:Texture2D;
var customSkin:GUISkin;
var customStyle:GUIStyle;

function OnGUI(){
GUI.skin = customSkin;
GUILayout.BeginArea(Rect(Screen.width/2-menuWidth/2,Screen.height/2-menuHeight/2,menuHeight,menuWidth),customStyle);
GUILayout.Space(50);
GUILayout.Label(titleTexture);
GUILayout.Space(buttonSpacing);
if(GUILayout.Button("Main Menu")){
Application.LoadLevel(mainMenu);
}
GUILayout.Space(buttonSpacing);
if(GUILayout.Button("Exit to Desktop")){
Application.Quit();
}
GUILayout.Space(buttonSpacing);
GUILayout.EndArea();
}

Thursday, February 9, 2012

Woah! two videos in one day!

I uploaded another video today. it's a tutorial. great learning experience. You guys must think I'm crazy with two videos within the same day! so take a look and enjoy! I'll be uploading the full script as soon as we get it finished! if you comment and stuff like that it encourages me to continue my work and it helps me out a lot!


New Project!

Here's an extremely small demo of our first project. it's just a couple hours of work. I learned a lot by making this, and  I will be making a tutorial on the Time class in unity. Let me know what you think and throw requests out there if you can! Thanks!



Oh yeah and the sounds are all from freesounds.org
Great place to go for, well, free sounds! Go ahead and check that out and if you'd like anymore info post a comment on here or on youtube!

Thursday, February 2, 2012

Main Menu

Here's the main menu script. Take a look, ask any questions in the comments.

//mainmenu.js by mactinite 
//Simple main menu
var areaHeight : float= 200;
var areaWidth : float= 200;
var layoutCenter : float = 100;
var firstLevel : String = "First";
var buttonSpacing : float = 25;
var customSkin : GUISkin;
var layoutStyle : GUIStyle;
var textureTop : Texture2D;
function OnGUI(){
GUI.skin = customSkin;
GUILayout.BeginArea(Rect(Screen.width/2-areaWidth/2,Screen.height/2-areaHeight/2,areaWidth,areaHeight),layoutStyle);
GUILayout.Space(25);
GUILayout.Label(textureTop);
GUILayout.Space(buttonSpacing);
 if(GUILayout.Button("Start Game")){
 Application.LoadLevel(firstLevel);
 }
GUILayout.Space(buttonSpacing);
 if(GUILayout.Button("Quit")){
 Application.Quit();
 }
GUILayout.EndArea();
}

Thursday, January 26, 2012

Sprint Script

Just a little script that makes the default FPS controller in unity have a sprint function.

//Sprinting with the default fpscontroller in Unity 3.0

var sprintSpeed : float = 15;
var defaultSpeed : float = 10;

//sets default run speed
function Start () {
 GetComponent(CharacterMotor).movement.maxForwardSpeed = defaultSpeed;
 }
//When the sprint button is pressed, change speed to sprint
function Update () {
if (Input.GetButtonDown("Sprint")){
  GetComponent(CharacterMotor).movement.maxForwardSpeed = sprintSpeed;
  }
//When the sprint button is let up, change back to walk speed
if (Input.GetButtonUp("Sprint")){
 GetComponent(CharacterMotor).movement.maxForwardSpeed = defaultSpeed;
}
}