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. Dismiss Notice

Unity lockst the position of prefabs in my scene in playmode!

Discussion in 'Scripting' started by Krassomat, Oct 4, 2020.

  1. Krassomat

    Krassomat

    Joined:
    Mar 7, 2020
    Posts:
    4
    I have ceated aempty gameObject, that parents all objects in my scene (exept for the character) an by script, i wanted it move backwards, to create the ollusion of moving the charcter itself. But when i started the script, it only moved the ground, because that was the only object in my scene, that was no prefap. How can i fix this? Please help!
     
  2. Terraya

    Terraya

    Joined:
    Mar 8, 2018
    Posts:
    646
    Maybe also insert the Code your using, so we can maybe help :eek:
     
  3. Krassomat

    Krassomat

    Joined:
    Mar 7, 2020
    Posts:
    4
    OK! This is it.
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class move : MonoBehaviour
    6. {
    7.     public Transform Everything;
    8.     // Start is called before the first frame update
    9.     void Start()
    10.     {
    11.  
    12.     }
    13.  
    14.     // Update is called once per frame
    15.     void Update()
    16.     {
    17.         Everything.Translate(Vector3.forward * 5 * Time.deltaTime);
    18.     }
    19. }
     
  4. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,731
    Are your prefabs marked as static?
     
    Terraya likes this.
  5. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Is "Everything" assigned? Are you seeing any console errors?
     
  6. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,756
    If you have an animation that drives the root object, that will also lock you in place. In that case, make a parent object and instantiate that instead.
     
  7. Krassomat

    Krassomat

    Joined:
    Mar 7, 2020
    Posts:
    4
    Thanks for your answer! But how do I know that?
     
  8. Krassomat

    Krassomat

    Joined:
    Mar 7, 2020
    Posts:
    4
    OK! It is so! Thank you!
     
    Munchy2007 likes this.