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 LeathalNinja1986 · Aug 16, 2012 at 09:11 PM · movementtransformdirectionspawner

tranform.TransformDirection not effecting spawned object

Ok so I am making a little game to show off my game design abilities for a portfolio. I've used a similar script in the past but for some reason it will not move the game character(chicken) after they spawn. All other components of the script function and I do not have any errors showing up so how do I get the chickens to ove forward if this method isn't going to work? Please help.

var Chicken_gunSpeed : float = 15.0;

var chicken : Rigidbody;

var fireRate = 1;

private var nextFire = 1;

static var chickenOn : boolean = false;

function Update () { if(Time.time > nextFire) { nextFire = Time.time + fireRate * Random.Range(2,5);

var cloneball = Instantiate (chicken, transform.position, transform.rotation);

cloneball.velocity = transform.TransformDirection (Vector3.forward * 50); }

}

Comment
Add comment · Show 3
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 beck · Aug 16, 2012 at 09:27 PM 0
Share

You should probably use Transform.InverseTransformDirection, since Vector3.forward is in world space. However, transform.InverseTransformDirection(Vector3.forward) is the same as transform.forward, except without the additional calculation (I think). Why not just cloneball.velocity = transform.forward * -50?

avatar image LeathalNinja1986 · Aug 16, 2012 at 11:01 PM 0
Share

Still didn't work, Chicken remains running in place.

avatar image beck · Aug 16, 2012 at 11:06 PM 0
Share

You may need to call the Rigidbody.WakeUp method to activate the rigidbody

2 Replies

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

Answer by ScroodgeM · Aug 17, 2012 at 07:26 AM

function Update ()
{
    if(Time.time > nextFire)
    {
        nextFire = Time.time + fireRate * Random.Range(2,5);
        var cloneball : Rigidbody;
        cloneball = Instantiate (chicken, transform.position, transform.rotation);
        //r u sure you want to make speed to backward???
        cloneball.velocity = transform.forward * -50;
    }
}
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 LeathalNinja1986 · Aug 20, 2012 at 04:09 PM 0
Share

Found the problem with the commands the object was receiving. The "cloneball.velocity = transform.forward * 50;" did the trick, thanks for responding to my question and getting an answer to me quickly.

avatar image
0

Answer by LeathalNinja1986 · Aug 20, 2012 at 04:11 PM

Script has no effect on the checkens movement after it spawns still.
How would I merge that Rigidbody.WakeUp to my script? I'm not familiar with it.

Comment
Add comment · Show 3 · 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 ScroodgeM · Aug 21, 2012 at 10:28 PM 0
Share

did you get any errors in console?

avatar image LeathalNinja1986 · Aug 22, 2012 at 02:53 AM 0
Share

None, had to make a couple tweaks so the characters move in the correct direction but no errors occurred.

avatar image ScroodgeM · Aug 23, 2012 at 10:22 PM 0
Share

does rigidbody is not set to kinematic?

check cloneball.velocity after applying the speed using Debug.Log() - what you see?

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

10 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

Related Questions

character movement at +/- 90° not working as expected 1 Answer

Transform position of an object at particular angle/direction 3 Answers

Updating rotation of client not working - strange error 0 Answers

Network Trasnform Interpolation Factor 2 Answers

Finding local position and clamping movement 2 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