Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

gravity script unity

// Keep in mind that this solution is for custom physics.
// The easy way to add gravity is to just slap a RigidBody component 
// on your objects.

using UnityEngine;

public class MyObject : MonoBehaviour
{
	public Vector3 speed;
	public float gravity = 9.8f;

	// Start() is called before the first frame
	void Start()
    {
    	speed = new Vector3(0f, 0f, 0f);
    }

	// FixedUpdate() is called at regular time intervals independent of frames
	void FixedUpdate()
	{
    	speed.Set(speed.x, speed.y - gravity * Time.fixedDeltaTime, speed.z);
        transform.position += speed;
	}
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# file exist 
Csharp :: asp textarea 
Csharp :: unity pause scene 
Csharp :: avoid autocomplete input text asp.net 
Csharp :: c# set int infinity 
Csharp :: c sharp int to string 
Csharp :: object list to csv c# 
Csharp :: the .net core sdk cannot be located unity 
Csharp :: vb.net open file with default program 
Csharp :: instantiate scale object 
Csharp :: how to make int to text unity 
Csharp :: how create another new app file in laravel 
Csharp :: unity change color of sprite in script 
Csharp :: c# negative index 
Csharp :: c# get random double in range 
Csharp :: how to get the path of the current directory in c# 
Csharp :: regex c# password numbers and letters 
Csharp :: Editor log location unity 
Csharp :: get directory name of path c# 
Csharp :: ef core detach entity 
Csharp :: bootrap modal 
Csharp :: remove carriage returns from string c# 
Csharp :: Prevent player rotation unity 
Csharp :: import time C# 
Csharp :: c# array of strings 
Csharp :: c# combine list of bool 
Csharp :: c# read file current directory 
Csharp :: unity create a child object 
Csharp :: .net Core Return File like File Server 
Csharp :: c# console foreground color 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =