Forum begins after the advertisement:


[Part 4] cant add weapon prefab to scriptableobject

Home Forums Video Game Tutorial Series Creating a Rogue-like Shoot-em Up in Unity [Part 4] cant add weapon prefab to scriptableobject

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #13118
    Ales V
    Level 3
    Participant
    Helpful?
    Up
    0
    ::

    here is the problem and code

    View post on imgur.com

    #13119
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    Hi Ales, you don’t assign the WeaponScriptableObject to the field. You need to create a prefab that contains the GarlicController script, then assign the prefab to the field. You need to assign the prefab of the projectile that the weapon spawns there.

    Let me know if this clarifies your question.

    #13120
    Ales V
    Level 3
    Participant
    Helpful?
    Up
    0
    ::

    You mean this? https://imgur.com/a/09LaPnq If yes than its there from the start that was not the issue.

    #13121
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    Ales, my bad. I meant you need to assign the prefab for the projectile onto the field, not the controller. Something like this:

    What to assign to the weapon data

    You can look at the section above (3) in the article: https://blog.terresquall.com/2022/12/creating-a-rogue-like-vampire-survivors-part-4#creating-enemy-stats

    #13122
    Ales V
    Level 3
    Participant
    Helpful?
    Up
    0
    ::

    I know but when i try to add it there i didnt see it i can only add prefab from scene and when i tried that there where the problem come out it write there Type mismatch https://imgur.com/a/ar4sN9U and i dont know how to fix that

    #13123
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    Are you sure you are assigning the projectile prefab? In your video it looks like you are assigning the weapon scriptable object file.

    #13124
    Ales V
    Level 3
    Participant
    Helpful?
    Up
    0
    ::

    I open up the Garlic Weapon (weapon Scriptable Object) than i click on the thing next to prefab and this will pop up. I can only add things from scene and when i add garlic weapon to scene and than i will put it there it will type type mismatch. This is what i see when i am putting things in the space(or how its called in English its right next to prefab text in the inspector). https://imgur.com/a/Ak8fhon

    #13126
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    Try dragging the prefab from the Project window instead. Let me know if you still get the same issue doing that.

    #13128
    Ales V
    Level 3
    Participant
    Helpful?
    Up
    0
    ::

    I cant drag it in.

    #13129
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    Can you show me a screenshot of the Inspector properties of the prefab you’re dragging in?

    #13130
    Ales V
    Level 3
    Participant
    Helpful?
    Up
    0
    ::

    Here you go this is my garlic weapon prefab https://imgur.com/g2UakED

    #13132
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    Ales, are you dragging the Garlic Weapon in from the Hierarchy? Did you prefab your Garlic Weapon GameObject before dragging it into the box?

    If you already have a prefab copy of it, don’t select it using the poup. Drag the prefab from the project window into the field. If it is in a different folder, you can lock the Inspector after selecting the Weapon Scriptable Object first, then navigate to the folder containing your prefab. Below is a picture of where the lock icon is.

    Locking the Inspector

    #13133
    Ales V
    Level 3
    Participant
    Helpful?
    Up
    0
    ::

    It works thank you very much for your help and time.

Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.

Go to Login Page →


Advertisement below: