Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by zigglr · Oct 01, 2015 at 02:32 PM · c#unity 5

Changing the speed of transform.translate?

I have the player automatically moving in a certain direction, and it is going too fast, so was just wondering how I can reduce this speed? Thanks

transform.Translate(0.10F, -0.055F, 0 * Time.deltaTime);

Comment
Add comment · Show 1
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 zigglr · Oct 01, 2015 at 04:09 PM 0
Share

I've tried changing Time.deltaTime to different integers but that didn't change the speed

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by bubzy · Oct 01, 2015 at 07:57 PM

0* anything is still 0 :)

change 0 to a variable called speed or something and delcare that as public in declarations like

 //in declarations
 float speed = 0.1f;  //change this value to change speed
 
 //in your function
 transform.Translate(0.1f,-0.05f,speed*Time.deltaTime);
Comment
Add comment · Show 6 · 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 zigglr · Oct 01, 2015 at 08:52 PM 0
Share

Hmm seems the player sprite just disappears off the screen when I do that

avatar image bubzy zigglr · Oct 01, 2015 at 09:53 PM 0
Share

so change the speed :) like 0.001f or 0.000000001f :D

avatar image zigglr · Oct 01, 2015 at 10:11 PM 0
Share

I think the z value is changing as character appears to go off the map (it's 2d)

avatar image bubzy · Oct 01, 2015 at 10:36 PM 0
Share

well, yes. you are using transform.Translate

the method for this is

public void Translate(float x, float y, float z, Transform relativeTo);

so you are entering the value on the Z axis as the position to increment, if you want this on a different axis, just put it in the other spot like

transform.Translate(0.1f,speed*Time.deltaTime,0); // for y axis

and so on, definitely worth using the scripting manual at http://docs.unity3d.com/ScriptReference/

avatar image zigglr · Oct 01, 2015 at 11:55 PM 0
Share

But then the sprite player will be moving in the wrong direction, if I replace the -0.05 with the speed * Time.deltaTime (the player is moving diagonally)

avatar image bubzy zigglr · Oct 02, 2015 at 09:09 AM 0
Share

it would be beneficial for you to start at the beginning and follow some tutorials.

avatar image
0

Answer by goffyram · Aug 11, 2017 at 07:50 PM

Using Time.deltaTime should get the Translate to change your speed. Try this:

Translate(1f Time.deltaTime, -.5f Time.deltaTime, speed * Time.deltaTime);

Comment
Add comment · 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
0

Answer by JackhammerGaming · Jul 30, 2019 at 10:59 AM

 public float trio;

 // Use this for initialization
 void Start () {

 }
 
 // Update is called once per frame
 void FixedUpdate () {
     if (Input.GetKey ("w")) {
         transform.Translate (0 , 0 , trio*Time.deltaTime);
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 JackhammerGaming · Jul 30, 2019 at 10:59 AM 0
Share

this should help you.

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

6 People are following this question.

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

Related Questions

Random Generation (Dungeon) with improvements in mind. 0 Answers

How to use the results of a dice roll? 2 Answers

How do i Instantiate sub-Points with in Multiple Points?? 0 Answers

OnCollisonEnter2D Not Firing after checking collider 1 Answer

Saved data gets overwritten 0 Answers


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