fly cam extended script unity 3d
C#
using UnityEngine;
using System.Collections;
public class ExtendedFlycam : MonoBehaviour
{
/*
EXTENDED FLYCAM
Desi Quintans (CowfaceGames.com), 17 August 2012.
Based on FlyThrough.js by Slin (http://wiki.unity3d.com/index.php/FlyThrough), 17 May 2011.
LICENSE
Free as in speech, and free as in beer.
FEATURES
WASD/Arrows: Movement
Q: Climb
E: Drop
Shift: Move faster
Control: Move slower
End: Toggle cursor locking to screen (you can also press Ctrl+P to toggle play mode on and off).
*/
public float cameraSensitivity = 90;
public float climbSpeed = 4;
public float normalMoveSpeed = 10;
public float slowMoveFactor = 0.25f;
public float fastMoveFactor = 3;
private float rotationX = 0.0f;
private float rotationY = 0.0f;
void Start ()
{
Screen.lockCursor = true;
}
void Update ()
{
rotationX += Input.GetAxis("Mouse X") * cameraSensitivity * Time.deltaTime;
rotationY += Input.GetAxis("Mouse Y") * cameraSensitivity * Time.deltaTime;
rotationY = Mathf.Clamp (rotationY, -90, 90);
transform.localRotation = Quaternion.AngleAxis(rotationX, Vector3.up);
transform.localRotation *= Quaternion.AngleAxis(rotationY, Vector3.left);
if (Input.GetKey (KeyCode.LeftShift) || Input.GetKey (KeyCode.RightShift))
{
transform.position += transform.forward * (normalMoveSpeed * fastMoveFactor) * Input.GetAxis("Vertical") * Time.deltaTime;
transform.position += transform.right * (normalMoveSpeed * fastMoveFactor) * Input.GetAxis("Horizontal") * Time.deltaTime;
}
else if (Input.GetKey (KeyCode.LeftControl) || Input.GetKey (KeyCode.RightControl))
{
transform.position += transform.forward * (normalMoveSpeed * slowMoveFactor) * Input.GetAxis("Vertical") * Time.deltaTime;
transform.position += transform.right * (normalMoveSpeed * slowMoveFactor) * Input.GetAxis("Horizontal") * Time.deltaTime;
}
else
{
transform.position += transform.forward * normalMoveSpeed * Input.GetAxis("Vertical") * Time.deltaTime;
transform.position += transform.right * normalMoveSpeed * Input.GetAxis("Horizontal") * Time.deltaTime;
}
if (Input.GetKey (KeyCode.Q)) {transform.position += transform.up * climbSpeed * Time.deltaTime;}
if (Input.GetKey (KeyCode.E)) {transform.position -= transform.up * climbSpeed * Time.deltaTime;}
if (Input.GetKeyDown (KeyCode.End))
{
Screen.lockCursor = (Screen.lockCursor == false) ? true : false;
}
}
}
Also in C#:
- Title
- interop C# save as and replace
- Category
- C#
- Title
- xamarin forms alarm
- Category
- C#
- Title
- uinput dialog uwp c#
- Category
- C#
- Title
- c# yield
- Category
- C#
- Title
- Unity C# instantiate prefab
- Category
- C#
- Title
- unity make a int arry with preset values
- Category
- C#
- Title
- c# long to int
- Category
- C#
- Title
- unity cycle children
- Category
- C#
- Title
- array copy c#
- Category
- C#
- Title
- create object in c#
- Category
- C#
- Title
- c# get full URL of page
- Category
- C#
- Title
- how to locate a specific element in a list c#
- Category
- C#
- Title
- how to create a list in c# unity
- Category
- C#
- Title
- debug.log
- Category
- C#
- Title
- take screenshot in c#
- Category
- C#
- Title
- c# check if type implements interface
- Category
- C#
- Title
- find gameobject with tag
- Category
- C#
- Title
- print gridcontrol devexpress
- Category
- C#
- Title
- c# null conditional
- Category
- C#
- Title
- exception handling c# stack overflow
- Category
- C#
- Title
- unity find object by name
- Category
- C#
- Title
- go right unity
- Category
- C#
- Title
- unity key detection
- Category
- C#
- Title
- unity how to rotate something to point to something else
- Category
- C#
- Title
- start a particle effect when a button is pushed
- Category
- C#
- Title
- generate a dropdown list from array data using razor .net mvc
- Category
- C#
- Title
- how to parse a string to an integer c#
- Category
- C#
- Title
- mongodb custom IIdGenerator
- Category
- C#
- Title
- unity try get component
- Category
- C#
- Title
- write last line txt file c#
- Category
- C#
- Title
- visual studio C# hintergrund bild ändern
- Category
- C#
- Title
- c# clear console read chache
- Category
- C#
- Title
- unity set sprite transparency
- Category
- C#
- Title
- .sh script: check if file exist
- Category
- C#
- Title
- c# get list of all class fields
- Category
- C#
- Title
- how to track a branch on github
- Category
- C#
- Title
- unity how to end a game with esc
- Category
- C#
- Title
- c# 2 timespan return yesterday
- Category
- C#
- Title
- c# ^ operator
- Category
- C#
- Title
- how to remove file changes in git
- Category
- C#
- Title
- verifyusertokenasync password reset token
- Category
- C#
- Title
- c# loop through two dimensional array
- Category
- C#
- Title
- how to get component in unity c#
- Category
- C#
- Title
- how to join array indexes with comma in c#
- Category
- C#
- Title
- get enum by index c#
- Category
- C#
- Title
- convert array to list Unity C#
- Category
- C#
- Title
- add object to list c#
- Category
- C#
- Title
- c# loop through list
- Category
- C#
- Title
- unity c# public all codes
- Category
- C#
- Title
- c# list tuple
- Category
- C#
- Title
- c# cheat sheet
- Category
- C#
- Title
- c# tuple access
- Category
- C#
- Title
- transform.Translate movement
- Category
- C#
- Title
- .net core authorizationhandlercontext
- Category
- C#
- Title
- unity rotate around point
- Category
- C#
- Title
- c# file exist
- Category
- C#
- Title
- unity rotate towards mouse
- Category
- C#
- Title
- add mime type for woff in web.config
- Category
- C#
- Title
- c# counting lines
- Category
- C#
- Title
- C# save pdf stream to file
- Category
- C#
- Title
- c# build string out of list of strings
- Category
- C#
- Title
- firefoxoptions setpreference to trust certificates
- Category
- C#
- Title
- c# expandoobject indexer
- Category
- C#
- Title
- countdown script in unity
- Category
- C#
- Title
- how to get length of okobjectresult c#
- Category
- C#
- Title
- c# remove from list in foreach
- Category
- C#
- Title
- c# ramdom
- Category
- C#
- Title
- as c#
- Category
- C#
- Title
- modificare una strinfa in c#
- Category
- C#
- Title
- C# move form without border
- Category
- C#
- Title
- convert string to datetime c#
- Category
- C#
- Title
- class selector to property in asp net core dropdown
- Category
- C#
- Title
- system.io.directorynotfoundexception c#
- Category
- C#
- Title
- ecs get specific entities with component
- Category
- C#
- Title
- unity gameobject.find
- Category
- C#
- Title
- c# keyboard enter
- Category
- C#
- Title
- c# change variable types
- Category
- C#
- Title
- lista generica como parametro de un metodo en c#
- Category
- C#
- Title
- access dic by key c#
- Category
- C#
- Title
- dto and automapper
- Category
- C#
- Title
- C# linq mselect
- Category
- C#
- Title
- c# type of generic is string
- Category
- C#
- Title
- codecademy
- Category
- C#
- Title
- c# udpclient receive buffer size
- Category
- C#
- Title
- unity detect any key
- Category
- C#
- Title
- or in unity
- Category
- C#
- Title
- how to make a string a list of characters c#
- Category
- C#
- Title
- downlaod file and use C#
- Category
- C#
- Title
- unity making homing missile
- Category
- C#
- Title
- Microsoft.AspNetCore.Components.Forms.InputSelect`1.TryParseValueFromString(String value, TValue& result, String& validationErrorMessage)
- Category
- C#
- Title
- two players one phone unity gamne
- Category
- C#
- Title
- c# nullable generic
- Category
- C#
- Title
- repeater itemdatabound event in c#
- Category
- C#
- Title
- c# foreach arra
- Category
- C#
- Title
- null coalescing operator c#
- Category
- C#
- Title
- c# input integer
- Category
- C#
- Title
- how to create public variable in c#
- Category
- C#
- Title
- usermanager change password without current password
- Category
- C#
- Title
- how to add to a list c#
- Category
- C#
- Title
- c# empty IEnumerable
- Category
- C#