Hi, i have a object that is moving, but i want it to speed up. Can i be done without using Rigidbody?!
var objectSpeed:float = 1;
var maxSpeed:float = 100;
var Acceleration:float = 5;
function Update () {
transform.position.z = -15;
transform.Translate(Vector3.up * objectSpeed * Acceleration * Time.deltaTime);
}
Just call an increment on your acceleration variable every time you run the Update() function, so long as the acceleration variable is smaller than your maxSpeed variable.
Here’s a simple script that will implement acceleration:
var acceleration : float;
var maxSpeed : float;
function Update() {
transform.Translate(0, acceleration * Time.deltaTime, 0);
if (acceleration < maxSpeed) {
acceleration += 1;
}
}
can any help me? Object Bounce slightly … i used rigibody.instead of i want to move smoothly … here is the code
using UnityEngine;
using System.Collections;
public class Cubemovewall : MonoBehaviour {
// Use this for initialization
public float speed = 15.0F;
//public float rotationSpeed =100.0f;
public float hormin=-5.8f;
public float hormax=5.8f;
public float playerspeed=3.0f;
void Start () {
}
// Update is called once per frame
void Update () {
Vector3 dir = Vector3.zero;
// dir.x = Input.acceleration.x;
//dir.y=-Input.acceleration.x;
// dir.y = Input.acceleration.y;
dir.x = -Input.acceleration.y;
if (dir.sqrMagnitude > 1)
dir.Normalize();
dir *= Time.deltaTime;
transform.Translate(dir * speed);
}
}