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
0
Question by TomMakesGames · May 14, 2013 at 10:33 AM · positionparentinheritanceorthellospace invaders

Object not inheriting transform from parent

I'm making a Space Invaders clone as a learning exercise (Unity beginner here).

When I press fire I want a shot to appear at the player's position of course (I haven't got to making the shot travel yet). At the moment when I press fire the 'playerShot' appears in the centre of the screen, not where the player is.

What am I doing wrong? The script is attached to the player object and so it should inherit the default position and rotation of the player shouldn't it?

The only idea I had was maybe it's an issue because I'm using Orthello2D? I was thinking of making my objects sprites rather than rigid bodies because I thought that would be more efficient. Am I wrong?

Code below. Any help much appreciated.

using UnityEngine; using System.Collections;

public class player : MonoBehaviour {

 //Figure used to change speed of left/right movement
 public float moveSpeed = 400.0f;
 public GameObject playerShot;

 
 // Use this for initialization
 void Start () {
 
 }
 
 // Update is called once per frame
 void Update () {
     
     //Setting variables and defining basic left/right player movement
     float h = Input.GetAxis("Horizontal") * Time.deltaTime * moveSpeed;
     transform.Translate(h, 0, 0);    
     
     //Fire mechanism

     if (Input.GetButtonUp("Fire1")){
         OTSprite newPlayerShot = Instantiate (playerShot, transform.position, transform.rotation) as OTSprite;    
     }
 }

}

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

1 Reply

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

Answer by sparkzbarca · May 14, 2013 at 11:35 AM

well you did say 2d.

a position and a rotation are 3 dimensional and i'm not sure how OTSprites work.

You need to look at the OTSprite documentation to see an example of how a sprite is spawned. Perhaps it uses vector2?

You could try spawning as a gameobject and then static casting to a sprite?

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 TomMakesGames · May 14, 2013 at 02:24 PM -1
Share

Thanks for helping.

Yeah, I'll delve into the Orthello docs to see what that gives. It's not as good as Unity's docs though :-( .

I also wasn't sure whether I should just spawn it as a rigidbody anyway. Is that bad practice?

Sorry for flood of noob questions - but what do you mean 'static casting' to a sprite?

Thanks again.

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

14 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

Related Questions

How can I identify a non-uniform scaled mesh, and fix it? 1 Answer

Why does Parented FBX keep transforming to 0,0,0 when i press play? 1 Answer

camera and positiong problems 1 Answer

how to stop child object from twitching? 1 Answer

C# Inheritance Problems 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