Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

shaking camera in c#

public IEnumerator Shake(float duration, float magnitude)
{
        Vector3 orignalPosition = transform.position;
        float elapsed = 0f;

        while (elapsed < duration)
        {
                float x = Random.Range(-1f, 1f) * magnitude;
                float y = Random.Range(-1f, 1f) * magnitude;

                transform.position = new Vector3(x, y, -10f);
                elapsed += Time.deltaTime;
                yield return 0;
        }
        transform.position = orignalPosition;
}
// this is coroutine function if you want to run it use the code below
// StartCoroutine(cameraShake.Shake(3f, 0.4f));
Comment

PREVIOUS NEXT
Code Example
Csharp :: string to date vb 
Csharp :: unity object follow mouse 
Csharp :: substring c# after character 
Csharp :: c# get project directory 
Csharp :: require admin pervillages c# 
Csharp :: unity character controller ignore collision 
Csharp :: c# iformfile to string 
Csharp :: system.text.json DeserializeAsync when to use 
Csharp :: unity convert mouse position to world position in editor mode 
Csharp :: how to choose a random child in a gameobject unuity 
Csharp :: c# get file extension 
Csharp :: mouse click unity raycast unity 
Csharp :: c# system.drawing.color to system.windows.media.color 
Csharp :: dyncmics 365 setstate request 
Csharp :: check if belnd tree plaiying 
Csharp :: unity system time 
Csharp :: snx turn off linux 
Csharp :: print unity 
Csharp :: Attach Mixer to Audio Source via script 
Csharp :: asp.net throw unauthorized exception 
Csharp :: c# how to open file explorer 
Csharp :: c# array remove first element 
Csharp :: the .net core sdk cannot be located unity 
Csharp :: c# dynamic object get value 
Csharp :: change array size in unity 
Csharp :: unity lock cursor to center 
Csharp :: how to get the path of the current directory in c# 
Csharp :: c# create file 
Csharp :: c# datagridview change column name 
Csharp :: validate data exist in database lara vel 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =