Showing posts with label Unity3D. Show all posts
Showing posts with label Unity3D. Show all posts

Friday, July 22, 2011

5 reasons not to rush to Unity

http://www.hypergridbusiness.com/2011/07/5-reasons-not-to-rush-to-unity/


Here are some possible reasons to stay away:
1. These are proprietary platforms. There are people and organizations who prefer to bet on open source software — because of cost, or because they can adapt it to their own needs.
2. You’re stuck with one vendor. You can’t move a Unity scene to, say, Flash or HTML 5 and WebGL without recreating it from scratch. And you can’t move a Jibe environment to Unifier without re-importing all the original constituent meshes.
3. You need to have meshes. That means having professional designers create your content. Free items from the Google Warehouse or individual objects bought in online mesh stores will only take you so far. A school won’t be able to have its students and teachers to create what they need for their classes — unless they’re part of a 3D design program.

Monday, July 18, 2011

Professional Top Down Shooter Game in Unity

http://forum.unity3d.com/threads/82719-3D-Top-Down-Shooter-Gamekit-now-on-Game-Prefabs?highlight=shooter

This new version of the top down shooter gamekit let you help to make very adictive top down shooters in 3D that have made popular with games like Minigore and Guerilla Bob.


This package will help you to shorten the development period of your game the maximum possible, withmore than 1500 lines of code divided in 40 Scripts that includes:

• 2 Types of player control: Typical Top Down Shooter and over-the-top third person shooter (Like ShadowGrounds games).



• 2 Game Modes: Stage Mode and Survival Mode, Including a “Bonus Level” too (Only added in Stage Mode)


• A fully Customizable AI with a large variety of parameters, that allows the enemies various types of actions like melee attack, shooting or jump over the player, between others. And a variation of this script with object avoidance.


• A Simple but very effective Spawn Director, that allows spawn enemies and items too. 
• Five Weapons divided in 3 types of shoot: Proyectiles, particles(FlameThrower) and explosives. 
• An arcade-like Stage Clear Scene.



• Dozens of global variables for gameplay seetings and player stats. 
• 5 types of items and a enemy loot script that let you configure the drop item game of everytype of enemy(prefab = type of enemy). 
• a customizable Melee weapon script.
• And much more...

Package Content:

• 3 test scenes: Control Type 1, Control Type 2 and Stage Clear. 
• All necesary art resources for prototyping. 
• 40 ready to use scripts.

PRICES: 

Special June Rebate Offer:

- 75% off from 1st June to 7th June (25$ Indie License)
- 66% off from 8th June to 15th June (33$ Indie License)
- 50% off from 16th June to 22th June (50$ Indie License)
- 33% off from 23th June to 31th June (66$ Indie License)

Once finished the offer, will have a permanent price of 75$ Indie.

Preview Demo:

- Preview 1: http://www.gameprefabs.com/products/preview/237
- Preview 2: http://dl.dropbox.com/u/2358594/3DTDSGAME2.html

Purchase Page:

- http://www.gameprefabs.com/products/show/237

List of Video tutorials for Unity Game Engine

http://unifycommunity.com/wiki/index.php?title=Tutorials

Unity FPS Shooter Game tutorial #6

http://unity3d.com/support/documentation/ScriptReference/Component.BroadcastMessage.html


Component.BroadcastMessage  

function BroadcastMessage (methodName : string, parameter : object = null, options : SendMessageOptions =SendMessageOptions.RequireReceiver) : void

Description

Calls the method named methodName on every MonoBehaviour in this game object or any of its children.
The receiving method can choose to ignore parameter by having zero arguments. if options is set toSendMessageOptions.RequireReceiver an error is printed when the message is not picked up by any component.
/// Calls the function ApplyDamage with a value of 5
BroadcastMessage ("ApplyDamage", 5.0);

// Every script attached to the game object and all its children
// that has a ApplyDamage function will be called.
function ApplyDamage (damage : float) {
print (damage);
}

Unity FPS Shooter Game tutorial #5

Picking up a weapon

var gotShotgun : boolean = false;
 var gunPickupSound : AudioClip;
 function Start ()
{ 
//playerWeapons is the players selectable weapons 
playerWeapons = this.GetComponent("PlayerWeapons");
 }
 function OnTriggerStay ()
{
 if (Input.GetButtonDown("Pickup"))
{ 
gotShotgun = true; 
Destroy(gameObject);
 //Play Gun Pickup Sound
 if (gunPickupSound) 
AudioSource.PlayClipAtPoint(gunPickupSound, transform.position); 
print("You Picked Up The Double Barel Shotgun"); 
}
 }

Sunday, July 3, 2011

Game Characters Polygon count



Paz! It's hard to believe, but the model for the small-framed Paz has 11,842 polygons!

Miller is no Paz, but he's got the details too, with 6,616 polygons for his model. This compares to the Pupa AI Weapon.


Snake! That's right, the character you see most often has just 1,631 polygons.

Thursday, June 30, 2011

Unity FPS Shooter Game Tutorial #4

Adding explosions to missiles that have been launched =====















as a reminder the projectile script is as below:

var explosion : GameObject;


function OnCollisionEnter( collision : Collision )
{
var contact : ContactPoint = collision.contacts[0];
var rotation = Quaternion.FromToRotation( Vector3.up, contact.normal );
var instantiatedExplosion : GameObject = Instantiate(
explosion, contact.point, rotation );
Destroy( gameObject );
}


Wednesday, June 29, 2011

Unity FPS Shooter Game Tutorial #3

Here is a modification in the launcher script to shoot two types of weapons
=================================================================================================================================================================================================================================

var projectile : Rigidbody;
var projectile2 : Rigidbody;
var speed = 20;

function Update () {


 if( Input.GetButtonDown( "Fire1" ) )
{

         var instantiatedProjectile : Rigidbody = Instantiate(
projectile, transform.position, transform.rotation );


instantiatedProjectile.velocity =
transform.TransformDirection( Vector3( 0, 0, speed ) );


   Physics.IgnoreCollision( instantiatedProjectile. collider,
     transform.root.collider );



}



if( Input.GetButtonDown( "Fire2" ) )
{

         var instantiatedProjectile2 : Rigidbody = Instantiate(
projectile2, transform.position, transform.rotation );


instantiatedProjectile2.velocity =
transform.TransformDirection( Vector3( 0, 0, speed ) );


   Physics.IgnoreCollision( instantiatedProjectile. collider,
     transform.root.collider );



}








}
==============================================================================================================================================================================================================================















Here is the two rigid bodies are a sphere (red sphere) and a cube(Xcube)

Unity FPS Shooter Game tutorial #2

Making the missile explode
======================================================================



var explosion : GameObject;
function OnCollisionEnter( collision : Collision )
{
 var contact : ContactPoint = collision.contacts[0];
 var rotation = Quaternion.FromToRotation( Vector3.up, contact.normal );
 var instantiatedExplosion : GameObject = Instantiate(
  explosion, contact.point, rotation );
 Destroy( gameObject );
}

========================================================================================================================================================

Finally,
we
 want 
to 
make
 the 
missile 
disappear 
from 
the
 game 
as 
it
 has 
now 
collided,

which 
is
 done 
by 
calling 
the 
Destroy()
 function 
with 
gameObject 
as 
a 
parameter

(gameObject 
denotes 
the
 object 
the 
script 
is 
associated
 with)


=====================================================================================================================================================


Add 
the
 code 
into 
the 
Projectile
 Javascript
 and
 save 
it.
Attach
 the
 Projectile
 Javascript 
to 
the
 Missile
 prefab 
by 
selecting
 Component
­>

Scripts
­>
Projectile.
Now 
we 
have 
to
 create 
the 
explosion 
that
 we
 want 
to 
occur
 when ever
 the
 missile 
col­
lides.
First,
create 
a
 new 
Prefab
 (call 
it 
Explosion)
 that 
will 
store 
the 
explosion 
asset.
The
 standard
 assets 
contain 
a 
nice 
explosion 
prefab 
with 
a 
particle
 system 
and 
a

light 
around 
the 
explosion.
Drag 
the 
explosion 
prefab 
under 
Standard
Assets/
Particles/explosion
 into 
the 
Hierarchy
 View.
Adjust
 the 
settings 
on 
the 
explosion 
until 
you’re 
happy 
with 
how 
it 
looks,
then

drag
 the 
Explosion 
from
 the 
Hierarchy 
view 
on to 
the 
Explosion 
Prefab
 in 
the

Project
 panel.
Now
 we 
can 
assign 
the 
explosion 
to 
the 
missile:
Ensuring
 that 
Missile 
prefab 
is 
selected,
 fill
 in 
the 
Explosion 
variable 
by 
dragging

the 
Explosion 
object 
in
 the 
Project 
panel 
onto
 the 
Missile’s
 Explosion 
variable
 in

the
 Inspector 
panel


Unity FPS Shooter Game tutorial


First we create an empty object called Launcher and then make it as a child of Main Camera and attach the script below to it  and give launcher an object that will be a  launched missile which has  to be a rigid body.
========================================================================

Here 
is  
the  
full  
code
  to
  MissileLauncher.js:
var projectile : Rigidbody;
var speed = 20;
function Update()
{
 if( Input.GetButtonDown( "Fire1" ) )
  {
  var instantiatedProjectile : Rigidbody = Instantiate(
   projectile, transform.position, transform.rotation );
  instantiatedProjectile.velocity =
   transform.TransformDirection( Vector3( 0, 0, speed ) );
  Physics.IgnoreCollision( instantiatedProjectile. collider,
   transform.root.collider );
  }
}


Tuesday, June 28, 2011

Instantiating Objects from an empty Game object



here is the script for the idea=========================================================================================================================================================================================================================

var object : Transform;




function Update () {

var theCloned : Transform;
theCloned = Instantiate(object,
transform.position, transform.rotation);




}
=============================================================================================================================================================================================================================

But here it is instantiating many Cubes that what we will change in the next script


Speed modeling for Cities in Games

 need to build a city level. With hi rise buildings, much of lites, etc. So, how is better to create buildings. To build each building in 3d tool, or create buildings from modules?

Little description. Buildings will be very hi. Like in "Blade Runner" or "Johnny Mnemonic". This is cyberpunk style, so you can imagine size of level and buildings. In some of them player can enter, and walk throw...




Idea#: I'd say write a script that generates the whole city from scratch. Mutch more interesting than spending hours building each building

the script will be creating buildings that are primitive Game objects 
============================================================================================================================================================================
Well, the fastest way, without using some sort of a script setup, is the block the whole city itself out with primative shapes, and then detail it down from there, you can decide what buildings are relevant enough that people will need to go inside them, and put interior stuff in those if thats how interactive it needs to be, otherwise just shape the outside of the city. By blocking it out first, you also insure the scale is how you want it
=========================================================================================================================================================================================================================================================



Getting animation to play all the way throughby pressing key once


I am trying to get an animation to play through all the way but it doesn't. The code I am using is:
function Update ()
 {
 if(Input.GetKeyDown("joystick button 2"))
 {
 animation.Play("HiroXAttack1");
 // name of the animation clip
 }
 }
======================================================================================================================================================

I have to press the button repeatedly to play the entire animation through.
I tried a different approach and did:
var isAttacking = false;
function Update ()
{
 if(Input.GetKeyDown("joystick button 2"))
 {
isAttacking = true;
 }
 if(isAttacking)
{
animation.Play("HiroXAttack1");
}

if(Input.anyKey == false)
{
 isAttacking = false;
 animation.Stop();
}
 }

=======================================================================================================================================================================

Your first code snippet should work, provided you have set your animation mode to Once, or Clamp, or ClampForever.
function Update ()
{
 if(Input.GetKeyDown("joystick button 2"))
 {
 animation.wrapMode = WrapMode.Once;
 animation.Play("HiroXAttack1");
// name of the animation clip
 }
}
==================================================================================================================================================

There is also a solution if you want the animations to be on the same layer. To play a given animation without stopping other animations on the same layer, you need to not use Animation.Play but instead do:
animation["MyOtherAnimation"].enabled = true;
animation["MyOtherAnimation"].weight = 1;
 animation["MyOtherAnimation"].time = 0;
==================================================================================================================================================


Lighting Idea=====> unity Game Idea

just like strategy games and some other games all places are dark and once you explore them the lights are turned on and you can see part of the map

=====================================================================================================================================================

psuedo code
====================================================================
function ontriggerenter()
{

  light.enabled=true;

}

How to play an animation all the way through on a single key


======================================================================================================================================================


var die1 : boolean;
var die2 : boolean; 
function Update() 
{
 if (Input.GetKeyDown(KeyCode.Alpha1))
 { die1 = true; 
die2 = false; 
} 
if (die1) 
{
 animation.CrossFade("die1"); 
animation.wrapMode = WrapMode.ClampForever; 
} 
if (Input.GetKeyDown(KeyCode.Alpha2)) 
{ die2 = true; die1 = false; }
 if (die2)
 { animation.CrossFade("die2"); 
animation.wrapMode = WrapMode.ClampForever; }
 else { 
animation.CrossFade("idle"); 
animation.wrapMode = WrapMode.Loop;
 } 
}

==================================================================================================================================================
if (die1) 
{
 if(animation.IsPlaying("die1"))
{ }
else
{
 animation.Play("die1"); 
} 
}
==================================================================================================================================================
the above code can be used to get an animation to play out fully without stopping on a single key press and even when you press the key again it shouldn't play, just double check that my "IsPlaying" method is used correctly

====================================================================================================================================================================
This seems to work just fine. Thank you all for your help.
==========================================================================================================================================================================================================================================================================================

function Start() 
{ 
animation["die1"].layer = 1; 
animation["die2"].layer = 1;
 } 
function Update() 
{ 
if (Mathf.Abs(Input.GetAxis("Vertical")) > 0.2)
 { 
animation.Stop("die1");
 animation.Stop("die2");
 if (Mathf.Abs(Input.GetAxis("Run")) > 0.2) 
{
 animation.CrossFade("run"); } 
else 
{ 
animation.CrossFade("walk");
 } } 
else if 
(Input.GetButton("Fire1"))
 {
 animation.Stop("die1");
 animation.Stop("die2"); 
animation["attack1"].wrapMode = WrapMode.Once; animation.Play("attack1"); 
} 
else if (Input.GetButton("Fire2")) 
{ 
animation.Stop("die1");
 animation.Stop("die2");
 animation["attack2"].wrapMode = WrapMode.Once;
 animation.Play("attack2"); 
} 

else if (Input.GetKeyDown(KeyCode.Alpha1)) 
{ 
animation["die1"].wrapMode = WrapMode.ClampForever; 
animation.CrossFade("die1"); 
} 
else if (Input.GetKeyDown(KeyCode.Alpha2))
 {
 animation["die2"].wrapMode = WrapMode.ClampForever; animation.CrossFade("die2"); 
} else { animation.CrossFade("idle"); 
}
 }
===========================================================================================================================================================

Play sound Once


To play a sound once during Update() use a boolean variable or instantiate a GameObject with an AudioSource with the same settings.
function Start() {
soundplayed = false;
 }

function Update ()
 {

 if (!soundplayed)
 {
  audio.PlayOneShot(blast);
  soundplayed = true;
 }
 ... }

how to make a animation play only when I get into the range of that game object?

 i have a game object that is an enemy. I want its animation to play only when I get really close to it.(im controllled by a fps player controller in my game) 



var rayCastLength = 5;
function Update () { var hit : RaycastHit;
//check if were in range... 
if(
Physics.Raycast(transform.position, transform.forward, hit, rayCastLength))
 { // ... 
with the object if(hit.collider.gameObject.tag == "lift_door") 
{
 //play the animation: hit.collider.gameObject.animation.Play("lift_door_open"); 
} 
}



}

Play animation and sound when GUI button is pressed



I have a GUI button that I have created. When the button is pressed I would like a game object to play a certain animation and also play a sound.
var lever : AudioClip;
if (GUI.Button (Rect(510,150,80,20), "Lever"))
 {
 animation.Play ("lever1"); 
audio.PlayOneShot(lever);
 }
=====================================================================================================================================================================
// Plays the default animation
animation.Play();
For a specific animation, you can call the animation with play as well.

// Plays the walk animation - stops all other animations in the same layer
animation.Play("walk");
// Plays the walk animation - stops all other animations
animation.Play("walk", PlayMode.StopAll);
====================================================================================================================================================================

AudioSource.PlayOneShot  

function PlayOneShot (clip : AudioClip, volumeScale : float = 1.0F) : void

Description

Plays an AudioClip.

// Play impact audio clip when colliding with something
var impact : AudioClip;
function OnCollisionEnter () {
audio.PlayOneShot(impact);
}

How to play entire animation?

how can i play entire animation when i hit an object or just simply pushing a button



For a button press


if(Input.GetButton("blah")){ do something;


or


if(Input.GetKey("a")){ do something;


OR

function OnControllerColliderHit(hit : ControllerColliderHit) 
{ 
 var player = GameObject.FindWithTag("w");

 if (hit.gameObject.tag =="w")
{
     player.animation.CrossFade("sit"); 
 }
 }

GameObject.CreatePrimitive




static function CreatePrimitive (type : PrimitiveType) : GameObject

Description

Creates a game object with a primitive mesh renderer and appropriate collider.

// Create a plane, sphere and cube in the scene.

function Start () {
var plane : GameObject = GameObject.CreatePrimitive(PrimitiveType.Plane);

var cube : GameObject = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube.transform.position = Vector3(0, 0.5, 0);

var sphere : GameObject = GameObject.CreatePrimitive(PrimitiveType.Sphere);
sphere.transform.position = Vector3(0, 1.5, 0);

var capsule : GameObject = GameObject.CreatePrimitive(PrimitiveType.Capsule);
capsule.transform.position = Vector3(2, 1, 0);

var cylinder : GameObject = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
cylinder.transform.position = Vector3(-2, 1, 0);
}