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 DubstepDragon · Jan 04, 2014 at 02:58 PM · scrollmagicspellfireball

Brackeys Inventory System doubts...

Hello all. I am using the Brackeys Inventory System for my project. However, I attempted to modify the health potion item into a magical scroll that fires a projectile and is then removed, similar to a consumable. This did not return errors, however does not have any effect whatsoever. And just to point out, I may be missing something, since this script is in JavaScript and I am only fluent in C#, however I do not have the time to convert the whole project.

Here is my (modified) code:

 #pragma strict
 
 //This script allows you to insert code when the Item is used (clicked on in the inventory).
 
 var deleteOnUse = true;
 
 var fireparticle : GameObject;
 var lightningparticle : GameObject;
 var iceparticle : GameObject;
 var arcaneparticle : GameObject;
 
 
 private var playersInv : Inventory;
 private var item : Item;
 
 @script AddComponentMenu ("Inventory/Items/Item Effect")
 @script RequireComponent(Item)
 
 //This is where we find the components we need
 function Awake ()
 {
     playersInv = FindObjectOfType(Inventory); //finding the players inv.
     if (playersInv == null)
     {
         Debug.LogWarning("No 'Inventory' found in game. The Item " + transform.name + " has been disabled for pickup (canGet = false).");
     }
     item = GetComponent(Item);
 }
 
 //This is called when the object should be used.
 function UseEffect () 
 {
 
     if(this.gameObject.CompareTag("HP")) {
         addHealth();
     }
 
     if(this.gameObject.CompareTag("FireballScroll")) {
         Instantiate(fireparticle);
     }
 
 //    if(this.gameObject.CompareTag("LightningballScroll")) {
 //        addHealth();
 //    }
             
 //    if(this.gameObject.CompareTag("IceballScroll")) {
 //        addHealth();
 //    }
                             
 //    if(this.gameObject.CompareTag("ArcaneballScroll")) {
 //        addHealth();
 //    }
                                                     
     //Play a sound
     playersInv.gameObject.SendMessage("PlayDropItemSound", SendMessageOptions.DontRequireReceiver);
     
     //This will delete the item on use or remove 1 from the stack (if stackable).
     if (deleteOnUse == true)
     {
         DeleteUsedItem();
     }
 }
 
 //This takes care of deletion
 function DeleteUsedItem()
 {
     if (item.stack == 1) //Remove item
     {
         playersInv.RemoveItem(this.gameObject.transform);
     }
     else //Remove from stack
     {
         item.stack -= 1;
     }
     Debug.Log(item.name + " has been deleted on use");
 }
 
 function addHealth() {
     Vitals.health += 25;
 }
 
 function fireball() {
     
 }
 
 function lightningball() {
     
 }
 
 function iceball() {
     
 }
 
 function arcaneball() {
     
 }




Thanks in advance! :D

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Owen Burk · Jan 04, 2014 at 03:13 PM

I'm not positive but instead of

 Instantiate(fireparticle);

try (Whatever transform you want)

 Instantiate (fireparticle, Vector3(0, 0, 0), Quaternion.identity);
Comment
Add comment · Show 5 · 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 DubstepDragon · Jan 04, 2014 at 06:15 PM 0
Share

Yes it works perfectly now; however, when I use the scroll, the fireball is launched at a random angle, which is not what I intend to do. I have an empty GameObject called SpellNode, from which I wish the fireball to fire from. The object is in front of the player, and I want the fireball to launch forwards. Can you help me? Thank you very much so far! :D

avatar image DubstepDragon · Jan 04, 2014 at 06:48 PM 0
Share

Can anyone please help me? I am in a hurry :'(

avatar image BigRoy · Jan 04, 2014 at 06:54 PM 0
Share

Use the position and rotation of the SpellNode object in the instantiate function.

 Instantiate(fireparticle, spellNodeTransform.position, spellNodeTransform.rotation);

Assu$$anonymous$$g you have access to the spellNode's transform.

avatar image DubstepDragon · Jan 05, 2014 at 02:01 PM 0
Share

They are still co$$anonymous$$g out at random angles :/

avatar image DubstepDragon · Jan 05, 2014 at 08:58 PM 0
Share

Please, I would like assistance with this as soon as possible, I am working under a deadline and need this by the end of the day. Thank you all.

avatar image
1

Answer by cwmanley · Jan 05, 2014 at 06:20 PM

Did you know there is a C# version on there website.

http://brackeys.com/?wpdmact=process&did=MTMuaG90bGluaw==

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 DubstepDragon · Jan 05, 2014 at 08:39 PM 0
Share

But that's not what I need. I already heavily modified this one, not going to start over again, thank you.

avatar image DubstepDragon · Jan 05, 2014 at 09:05 PM 0
Share

And the C# version does not work. When being exported there are loads of dependencies that were excluded.

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

21 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 avatar image avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

Magic mouse scroll-wheel 1 Answer

how to make a texture scroll on an object? 2 Answers

Trouble Adjusting Stats (MP After Casting A Spell) 2 Answers

Scroll to change walk speed... 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