Peek left and right

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
m (Text replace - "</javascript>" to "</syntaxhighlight>")
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
USAGE: Just place this script on the camera of your FPS player. This script will work for any game object but works best with a camera. Enjoy!
+
Author: [[User:Jediaction|Jediaction]]
  
 +
==Usage==
 +
Place this script on the camera of your FPS player. This script will work for any game object but works best with a camera. Enjoy!
 +
 +
Feel free to put it together if you would like to use it. It will take a little bit of tweeking but if you are not a basic basic user, this shouldnt be a problem.'''
 +
 +
<syntaxhighlight lang="javascript">
 
var cam : Transform;
 
var cam : Transform;
 
var nextPos = 0.0;
 
var nextPos = 0.0;
Line 7: Line 13:
 
var dampVelocity2 = 0.4;
 
var dampVelocity2 = 0.4;
  
function Update () {
+
function Update ()  
 +
{
 
   var newPos = Mathf.SmoothDamp(cam.transform.localPosition.x, nextPos, dampVelocity, .1);
 
   var newPos = Mathf.SmoothDamp(cam.transform.localPosition.x, nextPos, dampVelocity, .1);
 
   var newPos2 = Mathf.SmoothDamp(cam.transform.localPosition.y, nextPos2, dampVelocity2, .1);
 
   var newPos2 = Mathf.SmoothDamp(cam.transform.localPosition.y, nextPos2, dampVelocity2, .1);
Line 26: Line 33:
 
       nextPos2 = 1.5;
 
       nextPos2 = 1.5;
 
}
 
}
}
 
 
 
 
if(Input.GetKey("q"))
 
if(Input.GetKey("q"))
 
{
 
{
//adjust viewpoint and gun position
+
//adjust viewpoint and gun position
nextPos = -.6;
+
nextPos = -.6;
nextPos2 = 1.5;
+
nextPos2 = 1.5;
 +
}
 +
else
 +
{
 +
      //adjust viewpoint and gun position
 +
      nextPos = 0;
 +
      nextPos2 = 1.5;
 +
}
 
}
 
}
 +
</syntaxhighlight>

Latest revision as of 20:52, 10 January 2012

Author: Jediaction

[edit] Usage

Place this script on the camera of your FPS player. This script will work for any game object but works best with a camera. Enjoy!

Feel free to put it together if you would like to use it. It will take a little bit of tweeking but if you are not a basic basic user, this shouldnt be a problem.

var cam : Transform;
var nextPos = 0.0;
var nextPos2 = -0.2;
var dampVelocity = 0.4;
var dampVelocity2 = 0.4;
 
function Update () 
{
   var newPos = Mathf.SmoothDamp(cam.transform.localPosition.x, nextPos, dampVelocity, .1);
   var newPos2 = Mathf.SmoothDamp(cam.transform.localPosition.y, nextPos2, dampVelocity2, .1);
 
   cam.transform.localPosition.x = newPos;
   cam.transform.localPosition.y = newPos2;
 
   if(Input.GetKey("e"))
   {
       //adjust viewpoint and gun position
       nextPos = .6;
       nextPos2 = 1.5;
	} 
   else 
   {
       //adjust viewpoint and gun position
       nextPos = 0;
       nextPos2 = 1.5;
	}
	if(Input.GetKey("q"))
	{
		//adjust viewpoint and gun position
		nextPos = -.6;
		nextPos2 = 1.5;
	}
	else
	{
       //adjust viewpoint and gun position
       nextPos = 0;
       nextPos2 = 1.5;
	}
}
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox