Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by soupscooper · Oct 18, 2012 at 07:20 PM · objectspeed up

Object acceleration

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);
 
 }
 
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
6
Best Answer

Answer by THEpancakes · Oct 18, 2012 at 07:55 PM

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;
 }
 }
Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image soupscooper · Oct 18, 2012 at 08:01 PM 0
Share

thank you :)

avatar image shenglee83 · Nov 21, 2013 at 03:50 PM 0
Share

Good... This is very helpful...

avatar image ronin_42 · Jul 14, 2020 at 04:47 AM 0
Share

@THEpancakes can you tell me how to add this into my code

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class Vehicle$$anonymous$$ovement : $$anonymous$$onoBehaviour
 {
     public float speed = 10;
     // Start is called before the first frame update
     void Start()
     {
         
     }
 
     
     // Update is called once per frame
     void Update()
     {
         transform.Translate(new Vector3(0, 0, 1) * Time.deltaTime * speed);
     }
 }
 

i cant figure it out

avatar image
-2

Answer by RadhaUnity3d · Apr 12, 2013 at 03:06 PM

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);
 
 }

}

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bunny83 · Apr 12, 2013 at 03:17 PM 1
Share

If you want to ask a question, why have you posted an answer?

I'm just wondering who approved this post...

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

15 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Importing obj file with textures 5 Answers

getting the direction of object 1 Answer

Emmiter in time intervals 1 Answer

swapping out an object on collision 2 Answers

Problem with Object collision 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges