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 Brandon 8 · Jan 10, 2011 at 11:27 PM · shootturretworm

Help With Turret

hey guys im following a tutorial series on youtube and im on step 11....which can be found here

I can make the turret shoot but when i push spacebar the turret shoots instead of the worm. I dont understand what i did wrong.

Here is the code:

var LookAtTarget:Transform; var damp = 6.0; var bullitPrefab:Transform; var savedTime=0;

function Update () { if(LookAtTarget) { var rotate = Quaternion.LookRotation(LookAtTarget.position - transform.position);

         transform.rotation = Quaternion.Slerp(transform.rotation, rotate, Time.deltaTime * damp);

         var seconds : int = Time.time;
         var oddeven = (seconds % 2);

         if(oddeven)
         {

              Shoot(seconds);
         }
    }

}

function Shoot(seconds) {

   if(seconds !=savedTime)
   {
        var bullit = Instantiate(bullitPrefab ,transform.Find("spawnPoint").transform.position ,
                                  Quaternion.identity);

        bullit.rigidbody.AddForce(transform.forward * 1000);

        savedTime=seconds;
     }                            

}

If you cant help i understand. its ok. ill find help on their website hopefully if they ever write back. thanks anyway.

Comment
Add comment · Show 1
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 Statement · Jan 10, 2011 at 11:37 PM 0
Share

"If you cant help i understand. its ok. ill find help on their website hopefully if they ever write back. thanks anyway." It's funny you say that on a site dedicated to help people.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Statement · Jan 10, 2011 at 11:46 PM

I am not sure what you mean saying you're shooting when you press space bar. There is no line of code that mention space bar or even input in your example.

None the less, looking at the code I see that you instantiate the bullet at some object called "spawnPoint". If you want to instantiate the object on the same position as the script is on, you can modify that piece of code to

var bullit = Instantiate(bullitPrefab, transform.position, Quaternion.identity);

This require that your script is located on the worm.

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 Brandon 8 · Jan 11, 2011 at 12:33 AM 0
Share

i have to objects in my scene called spawn point. one for the turret to shoot and the other for the worm to shoot. I need to be able to shoot with the worm with spacebar and the turret to shoot by itself. which it does. its just when i hit spacebar it uses the turrets spawnpoint ins$$anonymous$$d of the worms spawnpoint and it shoots from the turret.

avatar image Statement · Jan 11, 2011 at 09:42 AM 0
Share

Oh ok, change name on the worms "spawnPoint" to "wormSpawnPoint" then?

avatar image Statement · Jan 11, 2011 at 09:43 AM 0
Share

There is no guarantee which one of the objects you'll get if they are named the same.

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

No one has followed this question yet.

Related Questions

firing a shell from a tank turret 1 Answer

Shooting at the nearest enemy automatically. 1 Answer

Mini Gun Turret 1 Answer

turret shoot if in range 1 Answer

Launch a projectile from one object to another 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