Hello, I need some help to get a Basic Sprint script… I tried to create a Ball game with a boost and it was a succes game and fun!
The problem is now that I’m going over to First-Person, and if anybody could help me with getting a Script where I can get the character(First-Person) to RUN, COOLDOWN(Stamina), and SHAKY camera when sprinting, only need some help with that.
Shaky Camera: Like the camera goes DOWN and then UP quick without the character changes viewpoint, just untill the sprint end, he walks normally.
This is the script I used for my ball game, but also wanted to try it out on my First-Person game, it didnt work as well but thats from my viewpoint. Let me just ask you one question: Do you think I can create Kind-Of sprinting like in Call of Duty and other games by using a BOOST-SCRIPT. Here is the script I use:
/// This script moves the character controller forward
/// and sideways based on the arrow keys.
/// It also jumps when pressing space.
/// Make sure to attach a character controller to the same game object.
/// It is recommended that you make only one call to Move or SimpleMove per frame.
var speed : float = 6.0;
var jumpSpeed : float = 8.0;
var gravity : float = 20.0;
var boostTimer : float = -0.01f;
var boostCooldown : float = -0.01f;
var boostExtra : float = 6.0f;
private var dead = false;
function OnControllerColliderHit(hit:ControllerColliderHit)
{
if(hit.gameObject.tag == "fallout")
{
dead = true;
}
}
private var moveDirection : Vector3 = Vector3.zero;
function Update() {
var controller : CharacterController = GetComponent(CharacterController);
if (controller.isGrounded) {
// We are grounded, so recalculate
// move direction directly from axes
moveDirection = Vector3(Input.GetAxis("Left/Right"), 0,
Input.GetAxis("Forward/Backward"));
moveDirection = transform.TransformDirection(moveDirection);
if(boostTimer>0.0f)
{
// This will give you a static boost. You might want to increase teh boostExtra
// from giving 0 extra in teh beginning but after 1 second give full speedbost, depends on your
//Implementation.
moveDirection *= (speed + boostExtra);
boostTimer -= Time.deltaTime;
}
else
{
moveDirection *= speed;
if(boostCooldown>0.0f)
boostCooldown -= Time.deltaTime;
}
if (Input.GetButton ("Jump") (boostTimer<0.0f)){
moveDirection.y = jumpSpeed;
}
//Call it whatever you want here
if(Input.GetButtonDown("Boost") (boostCooldown<0.0f)){
boostTimer = 5f;// The time(in seconds) you want the boost applied for
boostCooldown = 8f; // Seconds to delay another boost, AFTER the first boost is completed
}
}
// Apply gravity
moveDirection.y -= gravity * Time.deltaTime;
// Move the controller
controller.Move(moveDirection * Time.deltaTime);
}
function LateUpdate()
{
if(dead)
{
transform.position = Vector3(100,5,95);
gameObject.Find("Main Camera").transform.position = Vector3(100,0.5,-11);
dead = false;
}
}
Thank if you can help me!