Hello there.
I’m new at using Unity, and I have a little issue with the part 7 of the turorial (harming enemies)
The game is 100% functional, but when the player shoots, the line renderer that is drawn seems totally black sometimes, and sometimes it seems of the color of the material. I have been looking for solutions but haven’t been able to find one so far. These are the properties of my line renderer component
I don’t know this project well off the top of my head… But have you looked at LineRendererMaterial? Is this a pre-made material? Or do you set this up as part of the project? This may need to be updated to the standard shader or some other issue, but my guess is that the material you are using may be incompatible with Unity 5.
LineRenderMaterial was an included material but it may not behave super well in Unity 5 in certain build targets. I’d make sure your build settings are on PC/Mac/Linux Standalone and maybe switch the Shader to use the Standard Shader for better compatibility. I used the following settings and got a pretty comparable result:
It may also be worth turning Cast Shadows and Receive Shadows ‘off’ in the Line Renderer component for this effect to look correct.
Actually, I’ve just tested the project in 5.0.1 and it looks like the Line Renderer is bugged to show only as black under certain shaders.
If you’re running the project under Unity 5.0.1 I’d suggest changing LineRenderMaterial to use an Unlit/Color shader instead, and it should look as expected!
That actually worked!! really thanks!! I have finished the tutorial, and everything works excellent within Unity, BUT I have another issue. In the tutorial they do not explain how to build the proyect exactly, so I did it as the first two turorials explained, as a web player. But this does not seems to work, when I run the game, it pops up the same error several times. The error line is:
“SetDestination” can only be called on an active agent that has been placed on a NavMesh
After that, the enemies spawn but they do not move, the score text does not show and neither the game over text or the animation of the screen fader. However this error does not occur when I test in Unity, as I said before, and all the things I mentioned, work fine
I have 3 problems following the guide when working in Unity 5.x.:
The textures in the scene are not quite what they should be.
I was able to fix this by unchecking ‘Precomputed Realtime UI’ and ‘Baked UI’ under Lighting. I don’t know if this is the right procedure as I’m new to Unity.
On the Bake part of Navigation I have no ‘Width Inaccuracy %’. I used the value 0.1524761 for voxel size which almost gives the floor a complete blue baked area. Are there other options to do this in a proper way?
My biggest problem is when the player dies the game restarts and gets darker. I have no idea how to fix this. It happened after ch7. The repressing play the problem is gone but only till the player dies again and the game restarts.
I think its the same problem this person has:
Hope someone has an awnser to fix my 3rd problem as it is the most important. Thx in advance!
Hi @Hansel-Doullery ! My best guesses for this would be to double check when you’re building that you have the right scene selected in the ‘Scenes In Build’ section of the Build Settings window. There’s two scenes in the project by default (the starting point and the completed scene version), so it may be picking up the wrong one.
Alternatively, you may just need to tweak the Navmesh settings. I have some settings here that should work flawlessly, although they may not be the most optimised:
I briefly describe how to fix this in post #5 above, but basically Enlighten is automatically running in this scene in Unity 5 and baking bad data due to how the scene was set up for Unity 4. Selecting all the props and environment meshes and checking on Generate Lightmap UV’s as described above should fix this.
The settings I’ve just posted above should work for this too!
My best guess is that fixing the Lightmap UV’s on the scene objects will fix this error. let me know if it doesn’t and I’ll try and investigate further!
I found that when I turn off the ‘cast shadow’ on the floor object in the mesh renderer the textures are as they should be.
Also found out that when I leave ‘Precomputed Realtime UI’ and ‘Baked UI’ checked everything turns black when the game restarts and then the baking starts which takes about 5 minutes and takes almost all of my CPU capicity. When I uncheck ‘Precomputed Realtime UI’ and ‘Baked UI’ again the scenes is normal again.
For the last problem I can’t find the option you spoke of.
I quite new to Unity so sorry if I take your time asking simples things. If I go to the models folder and select each environment I dont have the option the change anything for it?
My apologies, I wasn’t very specific! I briefly outline in post #5 the steps to get Enlighten playing correctly with the scene so that you don’t get this problem. I’ll just copy-paste it here:
And here’s a screengrab showing the window, tab, and setting you’re looking for - just make sure to do this to all the environment models and hit apply!
Thx for your reply, I completely overlooked that tab. My apologies.
I checked all ‘Generate Lightmap UV’ boxes in Assets > Models > Environment and hit apply.
Nothing changed.
I have to note that when I started the project I dragged the Environment prefab from Assets > Predfab to the Hierarchy tree. Does hitting apply update it in the entire project?
Edit: something changed, the first problem I addressed is fixed. The weird textures are gone. But after I play the scene and the player died the screen still gets darker. After I press play again to stop the entire scene just gets black…
Edit2: I found out that the ‘getting darker’ is the same as when I uncheck ‘Continous Baking’ in the Lightning tab. Same intensity ‘darkning’ as when after the player died. Hope this helps.
Edit3: Found this post from a Unity dev:
Guess its just a bug that triggers on Application.LoadLevel and we can do nothing about it for now.
How can I change the gun accuracy with mouse, the way the game is design is to rotate the player with mouse position, but the aim are a little off because there are some offset from player position and gun position. how can i make the ray and line renderer to aim/cast the ray where my mouse is.
Hi everyone,
i’m currently doing the tutorial and am stuck on trying to figure out one thing, the enemy doesn’t seem to “attack” me and deplete my health, yet alone show the flash-of-the-screen indicator/slider life bar decrease. I’ve used the stock scripts from the assets store for both the player (e.g. “PlayerHealth”)
respectively for the “player health” part of the tutorial. I’ve even copied and pasted the C# coding from the webpage and still no depleting health.
i don’t get any errors from mono develop or unity itself, from the console etc and am able to run it well (except for the enemy not attacking/taking away my health).
i’ve even proceeded to the next part in the tutorial and complete “Harming enemies” and have been able to shoot the enemy and kill it, with no errors.
I don’t know this project that well, but: if your scripts are correct, it must be in the way you’ve set up your scene. Double check all the settings against the video and completed tutorial to see what’s gone off the rails.
Hi Adam,
thank you for replying. you know what? you’re absolutely correct, it was my scene setup with the player character, i was missing the entire capsule collider component, along with the audio hurt component. now everything’s coming up roses. thanks again mate!
i have a problem when i build the game, and run it
a light that show from gun is yellow, but light for Bullet is dark !
when i test game is perfect no problem, but after build and run that show this error !
Hello, I’ve been trying to go through this tutorial, I’m just done with the second part. I’ll keep going as it’s of little consequence (for now at least), but I have the “no animation” problem mentionned before. I did uncheck the “Has exit time” box on both transitions between walking and idle, I’m sure my code is correct (at some point I just went ahead and copied a confirmed functionnal one to be sure.
What else could be wrong?
What I find odd is that the gun is wobbling up and down when I walk around… feels like it’s the animation that is not working properly, in fact.
edit:
I checked all this, no problem there. I hit the convert button for the script too.
In the animator parameters, I have an entry box but no exit box, and I don’t really know what to do with that entry box, maybe it’s what causes the problem?
Hi, I have the same problem as** Venom2506** above. The gun is moving when the character transitions from Idle to Move, but the character body is not doing anything. I see the same issue when the character dies… the gun falls off but the character remains standing. I previewed the animation in the assets->models-characters folder and it seems to be working fine, but it doesn’t work during the game.
I too am having the same issue as richdinoso and Venom2506 where when the animations play only the gun will move, not sure if its somewhere I went wrong or if its a change unity 5