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 LagstonMcNac · Oct 05, 2016 at 12:09 PM · errortransformupdate

Transform not updating

Hey, so i'm using this code : using UnityEngine; using System.Collections;

public class Shoot : MonoBehaviour {

 public Rigidbody Balle;
 public Transform Pointdetir;

 // Use this for initialization
 void Start () {
 
 }
 
 // Update is called once per frame
 void Update () {
     if (Input.GetMouseButtonDown(0))
     {
         Instantiate(Balle, Pointdetir.position, Pointdetir.rotation);
         

     }
      


     
 
 }

} (don't care about weird variable names, i'm frenchy) But i want the game to update the transform of the empty Pointdetir object. It doesn't. I go in the inspector while walking around, it doesn't update. Also, I'd like to be able to put the abject Pointdetir that's already in the scene, not the prefab, but it doesn't work.

Any help?

Thanks in advance!

Comment
Add comment · Show 6
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 ScaniX · Oct 05, 2016 at 01:50 PM 1
Share

So, you attached this script to something other than the player (because if it was the player, you could just use transform.position and would not have the problem).

Then you drag in the player object into the inspector field "Pointdetir" (as what you say sounds as if this thing should be updated while the player walks around, so I guess you want the coordinates of the player here).

If you assigned something else than the player and expect the transform to be updated: What is updating the position of this object? Is it a child of the player? Is there some other script attached to it?

As you say this is a prefab, I assume it is either a more complex object that you use in multiple scenes or something that you dynamically instantiate. If you instantiate it somewhere per code, you need to set the reference there as well as a prefab cannot reference scene objects.

avatar image LagstonMcNac ScaniX · Oct 06, 2016 at 08:25 AM 0
Share

Was useful, but I need the Pointdetir object, not the player's. Pointdetir is basically the barrel the bullet shoots from.

avatar image ScaniX LagstonMcNac · Oct 06, 2016 at 09:54 AM 0
Share

Well, if you select the the object in the scene (not the prefab of course), drag the barrel scene object (again: not prefab) to the Pointdetir field and then move the barrel, then the value of Pointdetir will change as it will reference the Transform of the barrel.

The script is not the problem here, there seems to be something wrong with how the objects get set up. Cannot see it from here, though. ;)

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

97 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 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do I solve my Match 3 Game coding error?, 0 Answers

Setting the parent of an instantiated prefab error 1 Answer

[SOLVED] What to do instead of GameObject.Find("Somethingmoving").transform every frame? 1 Answer

Transforms update problem 0 Answers

Installation Problem! 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