Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 JohnnyD · Jun 14, 2011 at 01:25 AM · gunshootergrappling gun

Grappling Gun Help (shoot scripting help)

Well I have my (meshes) grappling gun made as well as the "Hook" projectile and attached to my Main Camera on my FPS charector controller. My problem I need more help with is i believe the firing (shoot) script I found on here subbed for my own reasons. Maybe it's not a shoot script but from what i know about java so far I do believe it is a shooting script. Take a look at it ::

 var projectile : Rigidbody;
 var initialSpeed = 20.0;
 var reloadTime = 0.5;
 var ammoCount = 20;
 private var lastShot = -10.0;
 var sound : AudioSource;
 var r : AudioClip;
 
 function Fire () {
     // Did the time exceed the reload time?
     if (Time.time > reloadTime + lastShot && ammoCount > 0) {
         // create a new projectile, use the same position and rotation as the Launcher.
         var instantiatedProjectile : Rigidbody = Instantiate (projectile, transform.position, transform.rotation);
 
         // Give it an initial forward velocity. The direction is along the z-axis of the missile launcher's transform.
         instantiatedProjectile.velocity = transform.TransformDirection(Vector3(0, 0, initialSpeed));
          sound.PlayOneShot(r);
 
         // Ignore collisions between the missile and the character controller
         Physics.IgnoreCollision(instantiatedProjectile.collider, transform.root.collider);
 
         lastShot = Time.time;
         ammoCount--;
 
     }
 }


The error at the bottom left of the screen says -- ArgumentException: You are not allowed to call Internal_CloneSingle when declaring a variable. Move it to the line after without a variable declaration. Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function. UnityEngine.Object.Instantiate (UnityEngine.Object original) (at C:/BuildAgent/work/6bc5f79e0a4296d6/Runtime/ExportGenerated/Editor/BaseClass.cs:65) NewBehaviourScript..ctor () (at Assets/NewBehaviourScript.js:1)

Don't know what it means obviously cause I didn't make the script but I still think it should work. Any thoughts or corrections I can fill in it that you all can help me with. It would be much appreciated -johnny

Comment
Add comment · 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 JohnnyD · Jun 14, 2011 at 02:41 AM 0
Share

Atleast I know is that im not deleting this and bout to give it another go--- Thank you Bunny83 and especially thanks for your time! :).

avatar image JohnnyD · Jun 14, 2011 at 02:41 AM 0
Share

For this newblet. x)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Jun 14, 2011 at 02:26 AM

Do just what the error suggested:

This line:

 var instantiatedProjectile : Rigidbody = Instantiate (projectile, transform.position, transform.rotation);

should look like this:

 var instantiatedProjectile : Rigidbody;
 instantiatedProjectile = Instantiate (projectile, transform.position, transform.rotation);
Comment
Add comment · 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

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

2 People are following this question.

avatar image avatar image

Related Questions

How do I put a delay on a gunshot? 2 Answers

Projectile Script! 0 Answers

how to make crosshair move slightly 1 Answer

How to script a response to an instantiation? 1 Answer

Help with fps script 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