Forum begins after the advertisement:


[Part 15] Whip Weapon not visible during attack

Home Forums Video Game Tutorial Series Creating a Rogue-like Shoot-em Up in Unity [Part 15] Whip Weapon not visible during attack

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #15179
    Nihkto
    Silver Supporter (Patron)

    Hello again, I set up a Particle System for a “rolling pin” attack for my game. I took the whip weapon script for that since the attack is very similar. The problem is that the particle System is not visible when the attack takes place. I know it is happening becuase I can see enemies taking damage and knockback. I did some debug logs and the particle System seems to be active. If I drag the prefab from the folder into the game or menu scene, it plays one time when I start the game, but it is visible then. When instantiated by code however, it is not visible.
    Thanks in advance.

    View post on imgur.com

    #15180
    Terence
    Keymaster

    When the whip effect is spawned by your script, does it show up in the Hierarchy? If it does, then it is likely that you have to set the Sorting Layer of your whip particle effects to a higher sorting layer.

    You can find the Sorting Layer ID property of a particle system in the Renderer module all the way at the bottom.

    Renderer module of the particle system.

    #15187
    Nihkto
    Silver Supporter (Patron)

    It doesn’t show up in the hierarchy, the only thing that shows up is the controller, but the particle System itself is never visible, which is strange because the particle system that is responsible for player damage spawns clones that are visible in the hierarchy. I set the Sorting Layer ID to Foreground.

    #15188
    Terence
    Keymaster

    If the whip effect is not showing up in your Hierarchy, it is not being spawned at all. Are there any errors appearing on your Console?

    I would check for the following:

    1. Make sure that your Whip weapon has a projectile prefab assigned, and make sure that you have assigned the prefab to it (and not a copy of the prefab on the Scene).
    2. Check and fix any errors in your Console
    3. If the above 2 doesn’t work, your script may have left something out. You can post it here and I’ll have a look at it for you.
    #15189
    Nihkto
    Silver Supporter (Patron)

    By Whip Weapon, you mean the Whip weapon Scriptable Object, right? I have assigned my particle system Prefab in the projectile prefab slot of the Whip weapon scriptable object. The particle effect prefab has the whip weapon script and the projectile weapon script assigned, is that how it should be? Because if the projectile Script is not attached, I cant assign the prefab in the scriptable Object. Unfortunately, I get no errors in my console, I even get spawn positions of the projectiles, but I cant see them. I´ll attach the script but I dont think that that´s the issue. Is there anything else you know of that could make the particle effect attack enemies without showing up in the hierarchy or being visible?

    View post on imgur.com

    #15193
    Terence
    Keymaster

    If the projectile doesn’t show up on the Hierarchy, it means that it is not spawning at all.

    Your Attack() function might not be firing, or might be firing only midway.

    Can you add the following lines:

    At line 21:
    print("Attack attempt");

    At line 23:
    print("Attack fired");

    At line 49:
    print("Prefab spawned: " + prefab.name);

    #15202
    Nihkto
    Silver Supporter (Patron)

    I did, this is what happens:

    View post on imgur.com

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

Go to Login Page →


Advertisement below: