c++ movment
C++
{
CharacterController characterController;
public float speed = 6.0f;
public float jumpSpeed = 8.0f;
public float gravity = 20.0f;
private Vector3 moveDirection = Vector3.zero;
void Start()
{
characterController = GetComponent<CharacterController>();
}
void Update()
{
if (characterController.isGrounded)
{
// We are grounded, so recalculate
// move direction directly from axes
moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0.0f, Input.GetAxis("Vertical"));
moveDirection *= speed;
if (Input.GetButton("Jump"))
{
moveDirection.y = jumpSpeed;
}
}
// Apply gravity. Gravity is multiplied by deltaTime twice (once here, and once below
// when the moveDirection is multiplied by deltaTime). This is because gravity should be applied
// as an acceleration (ms^-2)
moveDirection.y -= gravity * Time.deltaTime;
// Move the controller
characterController.Move(moveDirection * Time.deltaTime);
}
}
Also in C++:
- Title
- 2927260.eps 2927262.jpg 2927263.ai License free.txt License premium.txt
- Category
- C++
- Title
- how to delete an element in vector pair in cpp
- Category
- C++
- Title
- arduino falling edge
- Category
- C++
- Title
- c++ argv
- Category
- C++
- Title
- convert stirng to int c++
- Category
- C++
- Title
- heap in cpp stl
- Category
- C++
- Title
- remove item from layout
- Category
- C++
- Title
- string to number in c++
- Category
- C++
- Title
- append string to another string c++
- Category
- C++
- Title
- worker class c++
- Category
- C++
- Title
- c++ loop through int array
- Category
- C++
- Title
- inverser les éléments d'un tableau manuellement en c++
- Category
- C++
- Title
- c++ function return pointer to itself
- Category
- C++
- Title
- c++ declare char
- Category
- C++
- Title
- check for bst
- Category
- C++
- Title
- residuo en lenguaje c
- Category
- C++
- Title
- min coin change problem dp
- Category
- C++
- Title
- stack c++
- Category
- C++
- Title
- vector concat c++
- Category
- C++
- Title
- static variable in c++
- Category
- C++
- Title
- c++ uint32_t
- Category
- C++
- Title
- c++ files
- Category
- C++
- Title
- c++ do while loop
- Category
- C++
- Title
- how to avoid tle in c++
- Category
- C++
- Title
- how to iterate over unordered_map c++
- Category
- C++
- Title
- C++ int to char*
- Category
- C++
- Title
- c++ menu selection with arrow keys
- Category
- C++
- Title
- insert function in c++ vector
- Category
- C++
- Title
- c++ dereference a pointer
- Category
- C++
- Title
- how to sort a vector in c++
- Category
- C++
- Title
- cin.ignore
- Category
- C++
- Title
- unordered_map c++
- Category
- C++
- Title
- what is time complexity of insertion sort
- Category
- C++
- Title
- rand c++
- Category
- C++
- Title
- correct sequence of compilation process in c++
- Category
- C++
- Title
- how to turn int into string c++
- Category
- C++
- Title
- c++ char to int
- Category
- C++
- Title
- Operator overloading in C++ Programming
- Category
- C++
- Title
- c++ reset stream
- Category
- C++
- Title
- quick sort predefined function in c++
- Category
- C++
- Title
- file objects in c++
- Category
- C++
- Title
- dijkstra in c++
- Category
- C++
- Title
- find height of a tree
- Category
- C++
- Title
- c++ how to add something at the start of a vector
- Category
- C++
- Title
- remove element by index from vector c++
- Category
- C++
- Title
- range based for loop c++ with reference
- Category
- C++
- Title
- c++ switch case statement
- Category
- C++
- Title
- how to print 5 precision float in c++
- Category
- C++
- Title
- check if key exists in map c++
- Category
- C++
- Title
- if esle in c++
- Category
- C++
- Title
- bitset c++
- Category
- C++
- Title
- how to create a vector in c++
- Category
- C++
- Title
- cpp create lambda with recursion
- Category
- C++
- Title
- c++ initialization list
- Category
- C++
- Title
- c++ char define
- Category
- C++
- Title
- primitive and non primitive data types in c++
- Category
- C++
- Title
- c++ short if
- Category
- C++
- Title
- simple timer arduino blynk library error
- Category
- C++
- Title
- FInd the element which appears more than n/2 times C++
- Category
- C++
- Title
- opencv compile c++
- Category
- C++
- Title
- C++ Student::Student()
- Category
- C++
- Title
- array<string, 7> c++
- Category
- C++
- Title
- to_string c++
- Category
- C++
- Title
- set c++
- Category
- C++
- Title
- how to use a new node c++
- Category
- C++
- Title
- sieve of eratosthenes c++
- Category
- C++
- Title
- How to read a file in in C++
- Category
- C++
- Title
- std::reverse
- Category
- C++
- Title
- c++ random numbers
- Category
- C++
- Title
- preorder traversal
- Category
- C++
- Title
- find in vector in c++
- Category
- C++
- Title
- inheritance protected in c++
- Category
- C++
- Title
- how to compare lower case character to uppercase cpp
- Category
- C++
- Title
- elseif c++
- Category
- C++
- Title
- c++ formatting
- Category
- C++
- Title
- how to find the index of an element in a vector c++
- Category
- C++
- Title
- how to sort in descending order c++
- Category
- C++
- Title
- c++ vector add element
- Category
- C++
- Title
- binary search in set c++
- Category
- C++
- Title
- apple and orange hackerrank solution in c++
- Category
- C++
- Title
- sort a pair using c++ stl
- Category
- C++
- Title
- delete a double pointer c++
- Category
- C++
- Title
- how to get a letter from the user c++ string
- Category
- C++
- Title
- how to declare a vector in c++
- Category
- C++
- Title
- euler's totient function c++
- Category
- C++
- Title
- switch c++
- Category
- C++
- Title
- how to iterate through array in c++
- Category
- C++
- Title
- How to find the suarray with maximum sum using divide and conquer
- Category
- C++
- Title
- expected unqualified-id before 'if'
- Category
- C++
- Title
- translate
- Category
- C++
- Title
- c++ get last element in vector
- Category
- C++
- Title
- c++ get length of array
- Category
- C++
- Title
- error: redefinition of ‘class Customer’
- Category
- C++
- Title
- c++ code to print hello world
- Category
- C++
- Title
- how to get the prime number in c++ where time complexity is 0(log n)
- Category
- C++
- Title
- Get handle in C++
- Category
- C++
- Title
- uepic games github
- Category
- C++
- Title
- c++ method name
- Category
- C++
- Title
- std string find character c++
- Category
- C++
- Title
- c++ find object in vector by attribute
- Category
- C++