Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Translate not working visually

Discussion in 'Scripting' started by game4tress, May 15, 2015.

  1. game4tress

    game4tress

    Joined:
    May 13, 2010
    Posts:
    46
    I'm trying to move and rotate objects and, when I look at the inspector, the x, y and z axis are changing, but but visually, the objects are in the same place.
    I've made tests with a new scene and everything is working, but in this scene it isn't.
    this is the instruction I'm using:
    obj.transform.Translate(Time.deltaTime,Time.deltaTime,Time.deltaTime);
    Did anyone ever had this problem? How is it possible to solve it?
    My thanks in advanced
     
  2. steego

    steego

    Joined:
    Jul 15, 2010
    Posts:
    968
    That should work, but it's probably moving very slow. Try multiplying Time.deltaTime by 10-20 or so and it should be easier to see.
     
  3. SnakeTheRipper

    SnakeTheRipper

    Joined:
    Dec 31, 2014
    Posts:
    136
    The problem is that you are using Time.deltaTime and that usually is around 0.0xxxx so your object is moving very very slowly.

    Try using :

    Code (CSharp):
    1. float speed = 100;
    2.  
    3. obj.transform.Translate(new Vector3(1, 1, 1) * Time.deltaTime * speed);
     
  4. Korno

    Korno

    Joined:
    Oct 26, 2014
    Posts:
    518
    Your almost have the right idea. Using Time.deltaTime allows you to move in a framerate independent way - l guess you are using it for that reason.

    But

    You need to multiply a speed variable by Time.deltaTime as SnakeTheRippe shows above. That will give you the fraction of speed that you need to update your object this frame. Speed is thought as unity/second.

    Good Luck!
     
  5. game4tress

    game4tress

    Joined:
    May 13, 2010
    Posts:
    46
    Well, thank you all for your answers, but the problems is of another kind.
    After several test I found that by taking the "static" property of a basic Cube and of a 3D object I imported from Blender, that everything started to work.
    Now, why is this happening? Is this a normal behaviour?
     
  6. ThermalFusion

    ThermalFusion

    Joined:
    May 1, 2011
    Posts:
    906
    Yes, this is normal. Objects that are marked as Batching Static should never move.
     
  7. SnakeTheRipper

    SnakeTheRipper

    Joined:
    Dec 31, 2014
    Posts:
    136
    That's a basic thing. Static means that the object will NEVER move. This improves the performance of the game, so all your objects that don't move during runtime should be marked as static, for example, walls, buildings, trees (some do move), etc...