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 jlscott · Jul 11, 2013 at 11:50 PM · scipting

When I set an explosion prefab on my object the explosion is way off centered?

I am very very new to Unity3D and i'm sure most of you are laughing at how silly of a question this is. Basically I have been following the TornadoTwins tutorials on YouTube and we made a turret game. The turrets (once we hit them with out projectile) would blow up. We made a script (ill put a picture of it below) so when the projectile destroys the turret it also makes an explosion. I got everything to go off, but when the explosion goes off it is way off to the side and not right on top of the debris of the turret? I dont understand, so if anyone can help that would be great :Dalt text

rfdsfsa.jpg (49.6 kB)
explosion.jpg (159.2 kB)
Comment
Add comment · Show 8
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 Daniel G · Jul 12, 2013 at 12:21 AM 0
Share

haha, Hmm This is a simple question but there are LOTS of variables involved! Like maybe the explosion is set to go off in a different position? Ask yourself questions like: 1. Is my explosion prefab handel (that 3 direction arrow pointer thats in your scene view) off to one side of the explosion? if so that maybe your answer! 2. $$anonymous$$aybe your turrent is supposed to be in a specific place relative to the world? (Unlikely)

Hmm cant think of much more at the moment keep posting pictures, like off the explosion ect you can do this by clicking the pause button right beside the play game button right when the explosion is about to happen and then click the next frame button to play the game one frame at a time :D

avatar image pickle chips · Jul 12, 2013 at 12:33 AM 0
Share

haha I did that exact same tutorial when i was first learning!

Posing a pic that shows where the explosion occurs compared with the turret would allow me to help more.

avatar image jlscott · Jul 12, 2013 at 01:08 AM 0
Share

Ok I will do that real quick.

avatar image jlscott · Jul 12, 2013 at 01:14 AM 0
Share

alt text

help.jpg (94.8 kB)
avatar image pickle chips · Jul 12, 2013 at 01:30 AM 0
Share

The script IS attached to the turret, correct?

It could just be that the pivot point of the turret is just waay off. I see at the top you're moving around the center. See the button that says "center"? Click it, and then see if now when you try to rotate the turret it rotates around an odd axis.

Otherwise, I can tell you how to work around the problem, but it's not really solving it

Show more comments

1 Reply

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

Answer by pickle chips · Jul 12, 2013 at 01:49 AM

Since it is a problem the the model, instead of editing the pivot point in another program, what you can do is set an offset on the x and z axis to position it on the turret. To do this, add this to your code: (By the way, for the future it's better to actually post your code, instead of a picture.)

 //Add these variables here
 public var xOffset : float;
 public var zOffset : float;
 
 //Then when you instantiate it:
 var exp = Instantiate(explosion, Vector3(transform.position.x + xOffset, transform.position.y, transform.position.z + xOffset),Quaternion.identity );

This will instantiate it on the pivot point of the turret(where it is now), and then will move on the x and z axis according to the offset you assign it, which you can fiddle with in the inspector to get the right values.

If you still have problems leave a comment :p

Comment
Add comment · Show 2 · 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 jlscott · Jul 12, 2013 at 04:26 AM 0
Share
     //Add these variables here
     public var x -9.594989 : float;
     public var z -48.78781 : float;
    
     
     //Then when you instantiate it:
     var exp = Instantiate(explosion, Vector3(transform.position.x + xOffset, transform.position.y, transform.position.z + xOffset),Quaternion.identity );


Now I get errors from this?

avatar image ikelaiah · Jul 12, 2013 at 05:50 AM 0
Share

@jscott You might want to learn how to do Unity Scripting at Walker Boys Studios.

 var xOffset : float = -9.59f;
 var zOffset : float = -48.78f;

Pickle chips gave a good answer. If you are happy with it, you should accept the answer (although I'd still prefer to edit my 3D models manually, having the script suggested is a good idea too).

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

17 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

Related Questions

Help! My script wont work! 1 Answer

Help to code line of bullet like gunbound ! 1 Answer

I am not making Debug! 2D Toolkit and Unity 4 1 Answer

GUI Button to open an external document? HELP!!!! 3 Answers

Player model doesn't stay on ground 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