• 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
Question by PlatinumSkink · May 12, 2011 at 07:52 AM · instantiatemoveprojectileunresponsive

My instantiated projecttile refuses to move

var Missile : Rigidbody;
var localOffput : Vector3 = new Vector3(200, 200, 200);
var SpawnPlace : Vector3 = new Vector3(0, 0, 0);
var startingSpeed : int = 30;
function Update () {
    SpawnPlace = new Vector3(transform.position.x, transform.position.y, transform.position.z);
}
function Blast () {
    Debug.Log("I'M FIIRIN MY MISSILWE!!!");
    var newMissile : Rigidbody;
    newMissile = Instantiate (Missile, Vector3(transform.position.x, transform.position.y, transform.position.z), gameObject.transform.rotation);
    //PlayerSpeed = transform.Find("Capsule");
    //newMissile.rigidbody.velocity = GameObject.Find("Wings").rigidbody.velocity;
    //newMissile.angularVelocity = GameObject.Find("Wings").rigidbody.angularVelocity;
    //newMissile.velocity += transform.TransformDirection(Vector3.forward * startingSpeed);
    newMissile.rigidbody.AddForce(transform.forward * startingSpeed);
    //newMissile.velocity += transform.TransformDirection(Vector3 (0, 0, startingSpeed));
    //newMissile.velocity = new Vector3(300, 300, 300);
    Physics.IgnoreCollision(newMissile.collider, transform.root.collider);
}

OK, I have no idea why my instantiated missile refuses to move, no matter what kind of code I put on it. In fact, it does not seem to at all be affected by anything I code after I instantiate it. What could cause such a behaviour? What have I forgot to do?

Comment

People who like this

0 Show 2
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 PlatinumSkink · May 12, 2011 at 08:04 AM 0
Share

... Why cannot I modify my question to correct the word "projecttile"..? Or is it simply that I cannot detect the means of doing so..?

avatar image PlatinumSkink · May 12, 2011 at 08:13 AM 0
Share

Swii... It does not even ignore collisions, despite that last row of code...

2 Replies

  • Sort: 
avatar image

Answer by loopyllama · May 12, 2011 at 08:30 AM

you are adding a force on a single frame and I bet it is working. It is just a very small force. Try making your startingSpeed number very large. Perhaps you should control the movement by adding a small amount to the position each frame rather than use the physics system.

Comment

People who like this

0 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 Antony-Blackett · May 12, 2011 at 08:33 AM 0
Share

I would use the physics system myself.

avatar image loopyllama · May 12, 2011 at 08:49 AM 0
Share

using the physics system to move a rocket is like opening a bag of chips with a sledgehammer. yes, it will indeed work.

avatar image

Answer by Antony-Blackett · May 12, 2011 at 08:35 AM

Try changing the AddForce line to this.

newMissile.rigidbody.AddForce(transform.forward * startingSpeed, ForceMode.VelocityChange );

Comment

People who like this

0 Show 0 · 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

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta by June 9. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Make multiple Projectiles move at the same Time... 0 Answers

move FP controller on trigger enter? 0 Answers

instantiate finding upstream velocity 1 Answer

2D Space Shooter Instantiating bullet question 1 Answer

Changing the sprite of an instantiated object through a collision box from another gameobject. 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