• Advertisement

Search the Community

Showing results for tags 'C\#'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Categories

  • Audio
    • Music and Sound FX
  • Business
    • Business and Law
    • Career Development
    • Production and Management
  • Game Design
    • Game Design and Theory
    • Writing for Games
    • UX for Games
  • Industry
    • Interviews
    • Event Coverage
  • Programming
    • Artificial Intelligence
    • General and Gameplay Programming
    • Graphics and GPU Programming
    • Engines and Middleware
    • Math and Physics
    • Networking and Multiplayer
  • Visual Arts
  • Archive

Categories

  • News

Categories

  • Audio
  • Visual Arts
  • Programming
  • Writing

Categories

  • GameDev Unboxed

Categories

  • Game Dev Loadout

Categories

  • Game Developers Conference
    • GDC 2017
    • GDC 2018
  • Power-Up Digital Games Conference
    • PDGC I: Words of Wisdom
    • PDGC II: The Devs Strike Back
    • PDGC III: Syntax Error

Forums

  • Audio
    • Music and Sound FX
  • Business
    • Games Career Development
    • Production and Management
    • Games Business and Law
  • Game Design
    • Game Design and Theory
    • Writing for Games
  • Programming
    • Artificial Intelligence
    • Engines and Middleware
    • General and Gameplay Programming
    • Graphics and GPU Programming
    • Math and Physics
    • Networking and Multiplayer
  • Visual Arts
    • 2D and 3D Art
    • Critique and Feedback
  • Topical
    • Virtual and Augmented Reality
    • News
  • Community
    • For Beginners
    • GameDev Challenges
    • GDNet+ Member Forum
    • GDNet Lounge
    • GDNet Comments, Suggestions, and Ideas
    • Coding Horrors
    • Your Announcements
    • Hobby Project Classifieds
    • Indie Showcase
    • Article Writing
  • Affiliates
    • NeHe Productions
    • AngelCode
  • Workshops
    • C# Workshop
    • CPP Workshop
    • Freehand Drawing Workshop
    • Hands-On Interactive Game Development
    • SICP Workshop
    • XNA 4.0 Workshop
  • Archive
    • Topical
    • Affiliates
    • Contests
    • Technical
  • GameDev Challenges's Topics

Calendars

  • Community Calendar
  • Games Industry Events
  • Game Jams
  • GameDev Challenges's Schedule

Blogs

There are no results to display.

There are no results to display.

Developers

Developers


Group


About Me


Website


Industry Role


Twitter


Github


Twitch


Steam

Found 260 results

  1. Recently a long-awaited event has happen - Unity Technologies uploaded the C# source code of the game engine, available for free download on Github. The code of the engine and the editor is available. Of course, we couldn't pass up, especially since lately we've not written so many articles about checking projects on C#. Unity allows to use the provided sources only for information purposes. We'll use them exactly in these ways. Let's try out the latest version PVS-Studio 6.23 on the Unity code. Introduction Previously we've written an article about checking Unity. At that time so much C#-code was not available for the analysis: some components, libraries and examples of usage. However, the author of the article managed to find quite interesting bugs. How did Unity please us this time? I'm saying "please" and hope not to offend the authors of the project. Especially since the amount of the source Unity C#-code, presented on GitHub, is about 400 thousand lines (excluding empty) in 2058 files with the extension "cs". It's a lot, and the analyzer had a quite considerable scope. Now about the results. Before the analysis, I've slightly simplified the work, having enabled the mode of the code display according to the CWE classification for the found bugs. I've also activated the warnings suppression mechanism of the third level of certainty (Low). These settings are available in the drop-down menu of PVS-Studio in Visual Studio development environment, and in the parameters of the analyzer. Getting rid of the warnings with low certainty, I made the analysis of the Unity source code. As a result, I got 181 warnings of the first level of certainty (High) and 506 warnings of the second level of certainty (Medium). I have not studied absolutely all the warnings, because there were quite a lot of them. Developers or enthusiasts can easily conduct an in-depth analysis by testing Unity themselves. To do this, PVS-Studio provides free trial and free modes of using. Companies can also buy our product and get quick and detailed support along with the license. Judging by the fact that I immediately managed to find couple of real bugs practically in every group of warnings with one or two attempts, there are a lot of them in Unity. And yes, they are diverse. Let's review the most interesting errors. Results of the check Something's wrong with the flags PVS-Studio warning: V3001 There are identical sub-expressions 'MethodAttributes.Public' to the left and to the right of the '|' operator. SyncListStructProcessor.cs 240 MethodReference GenerateSerialization() { .... MethodDefinition serializeFunc = new MethodDefinition("SerializeItem", MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.Public | // <= MethodAttributes.HideBySig, Weaver.voidType); .... } When combining enumeration flags MethodAttributes, an error was made: the Public value was used twice. Perhaps, the reason for this is the wrong code formatting. A similar bug is also made in code of the method GenerateDeserialization: V3001 There are identical sub-expressions 'MethodAttributes.Public' to the left and to the right of the '|' operator. SyncListStructProcessor.cs 309 Copy-Paste PVS-Studio warning: V3001 There are identical sub-expressions 'format == RenderTextureFormat.ARGBFloat' to the left and to the right of the '||' operator. RenderTextureEditor.cs 87 public static bool IsHDRFormat(RenderTextureFormat format) { Return (format == RenderTextureFormat.ARGBHalf || format == RenderTextureFormat.RGB111110Float || format == RenderTextureFormat.RGFloat || format == RenderTextureFormat.ARGBFloat || format == RenderTextureFormat.ARGBFloat || format == RenderTextureFormat.RFloat || format == RenderTextureFormat.RGHalf || format == RenderTextureFormat.RHalf); } I gave a piece of code, preliminary having formatted it, so the error is easily detected visually: the comparison with RenderTextureFormat.ARGBFloat is performed twice. In the original code, it looks differently: Probably, another value of enumeration RenderTextureFormat has to be used in one of two identical comparisons. Double work PVS-Studio warning: V3008 CWE-563 The 'fail' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 1633, 1632. UNetWeaver.cs 1633 class Weaver { .... public static bool fail; .... static public bool IsValidTypeToGenerate(....) { .... if (....) { .... Weaver.fail = true; fail = true; return false; } return true; } .... } The true value is assigned twice to the value, as Weaver.fail and fail is one and the same static field of the Weaver class. Perhaps, there is no crucial error, but the code definitely needs attention. No options PVS-Studio warning: V3009 CWE-393 It's odd that this method always returns one and the same value of 'false'. ProjectBrowser.cs 1417 // Returns true if we should early out of OnGUI bool HandleCommandEventsForTreeView() { .... if (....) { .... if (....) return false; .... } return false; } The method always returns false. Pay attention to the comment in the beginning. A developer forgot about the result PVS-Studio warning: V3010 CWE-252 The return value of function 'Concat' is required to be utilized. AnimationRecording.cs 455 static public UndoPropertyModification[] Process(....) { .... discardedModifications.Concat(discardedRotationModifications); return discardedModifications.ToArray(); } When concatenating two arrays discardedModifications and discardedRotationModifications the author forgot to save the result. Probably a programmer assumed that the result would be expressed immediately in the array discardedModifications. But it is not so. As a result, the original array discardedModifications is returned from the method. The code needs to be corrected as follows: static public UndoPropertyModification[] Process(....) { .... return discardedModifications.Concat(discardedRotationModifications) .ToArray(); } Wrong variable was checked PVS-Studio warning: V3019 CWE-697 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'obj', 'newResolution'. GameViewSizesMenuItemProvider.cs 104 private static GameViewSize CastToGameViewSize(object obj) { GameViewSize newResolution = obj as GameViewSize; if (obj == null) { Debug.LogError("Incorrect input"); return null; } return newResolution; } In this method, the developers forgot to consider a situation where the variable objis not equal to null, but it will not be able to cast to the GameViewSize type. Then the variable newResolution will be set to null, and the debug output will not be made. A correct variant of code will be like this: private static GameViewSize CastToGameViewSize(object obj) { GameViewSize newResolution = obj as GameViewSize; if (newResolution == null) { Debug.LogError("Incorrect input"); } return newResolution; } Deficiency PVS-Studio warning: V3020 CWE-670 An unconditional 'return' within a loop. PolygonCollider2DEditor.cs 96 private void HandleDragAndDrop(Rect targetRect) { .... foreach (....) { .... if (....) { .... } return; } .... } The loop will execute only one iteration, after that the method terminates its work. Various scenarios are probable. For example, return must be inside the unit if, or somewhere before return, a directive continue is missing. It may well be that there is no error here, but then one should make the code more understandable. Unreachable code PVS-Studio warning: V3021 CWE-561 There are two 'if' statements with identical conditional expressions. The first 'if' statement contains method return. This means that the second 'if' statement is senseless CustomScriptAssembly.cs 179 public bool IsCompatibleWith(....) { .... if (buildingForEditor) return IsCompatibleWithEditor(); if (buildingForEditor) buildTarget = BuildTarget.NoTarget; // Editor .... } Two identical checks, following one after another. It is clear that in case of buildingForEditor equality to the true value, the second check is meaningless, because the first method terminates its work. If the value buildingForEditor is false, neither then-brunch nor if operator will be executed. There is an erroneous construction that requires correction. Unconditional condition PVS-Studio warning: V3022 CWE-570 Expression 'index < 0 && index >= parameters.Length' is always false. AnimatorControllerPlayable.bindings.cs 287 public AnimatorControllerParameter GetParameter(int index) { AnimatorControllerParameter[] param = parameters; if (index < 0 && index >= parameters.Length) throw new IndexOutOfRangeException( "Index must be between 0 and " + parameters.Length); return param[index]; } The condition of the index check is incorrect - the result will always be false. However, in case of passing the incorrect index to the GetParameter method, the exception IndexOutOfRangeException will still be thrown when attempting to access an array element in the return block. Although, the error message will be slightly different. One has to use || in a condition instead of the operator && so that the code worked the way a developer expected: public AnimatorControllerParameter GetParameter(int index) { AnimatorControllerParameter[] param = parameters; if (index < 0 || index >= parameters.Length) throw new IndexOutOfRangeException( "Index must be between 0 and " + parameters.Length); return param[index]; } Perhaps, due to the use of the Copy-Paste method, there is another the same error in the Unity code: PVS-Studio warning: V3022 CWE-570 Expression 'index < 0 && index >= parameters.Length' is always false. Animator.bindings.cs 711 And another similar error associated with the incorrect condition of the check of the array index: PVS-Studio warning: V3022 CWE-570 Expression 'handle.valueIndex < 0 && handle.valueIndex >= list.Length' is always false. StyleSheet.cs 81 static T CheckAccess<T>(T[] list, StyleValueType type, StyleValueHandle handle) { T value = default(T); if (handle.valueType != type) { Debug.LogErrorFormat(.... ); } else if (handle.valueIndex < 0 && handle.valueIndex >= list.Length) { Debug.LogError("Accessing invalid property"); } else { value = list[handle.valueIndex]; } return value; } And in this case, a release of the IndexOutOfRangeException exception is possible.As in the previous code fragments, one has to use the operator || instead of && to fix an error. Simply strange code Two warnings are issued for the code fragment below. PVS-Studio warning: V3022 CWE-571 Expression 'bRegisterAllDefinitions || (AudioSettings.GetSpatializerPluginName() == "GVR Audio Spatializer")' is always true. AudioExtensions.cs 463 PVS-Studio warning: V3022 CWE-571 Expression 'bRegisterAllDefinitions || (AudioSettings.GetAmbisonicDecoderPluginName() == "GVR Audio Spatializer")' is always true. AudioExtensions.cs 467 // This is where we register our built-in spatializer extensions. static private void RegisterBuiltinDefinitions() { bool bRegisterAllDefinitions = true; if (!m_BuiltinDefinitionsRegistered) { if (bRegisterAllDefinitions || (AudioSettings.GetSpatializerPluginName() == "GVR Audio Spatializer")) { } if (bRegisterAllDefinitions || (AudioSettings.GetAmbisonicDecoderPluginName() == "GVR Audio Spatializer")) { } m_BuiltinDefinitionsRegistered = true; } } It looks like an incomplete method. It is unclear why it has been left as such and why developers haven't commented the useless code blocks. All, that the method does at the moment: if (!m_BuiltinDefinitionsRegistered) { m_BuiltinDefinitionsRegistered = true; } Useless method PVS-Studio warning: V3022 CWE-570 Expression 'PerceptionRemotingPlugin.GetConnectionState() != HolographicStreamerConnectionState.Disconnected' is always false. HolographicEmulationWindow.cs 171 private void Disconnect() { if (PerceptionRemotingPlugin.GetConnectionState() != HolographicStreamerConnectionState.Disconnected) PerceptionRemotingPlugin.Disconnect(); } To clarify the situation, it is necessary to look at the declaration of the methodPerceptionRemotingPlugin.GetConnectionState(): internal static HolographicStreamerConnectionState GetConnectionState() { return HolographicStreamerConnectionState.Disconnected; } Thus, calling the Disconnect() method leads to nothing. One more error relates to the same method PerceptionRemotingPlugin.GetConnectionState(): PVS-Studio warning: V3022 CWE-570 Expression 'PerceptionRemotingPlugin.GetConnectionState() == HolographicStreamerConnectionState.Connected' is always false. HolographicEmulationWindow.cs 177 private bool IsConnectedToRemoteDevice() { return PerceptionRemotingPlugin.GetConnectionState() == HolographicStreamerConnectionState.Connected; } The result of the method is equivalent to the following: private bool IsConnectedToRemoteDevice() { return false; } As we can see, among the warnings V3022 many interesting ones were found. Probably, if one spends much time, he can increase the list. But let's move on. Not on the format PVS-Studio warning: V3025 CWE-685 Incorrect format. A different number of format items is expected while calling 'Format' function. Arguments not used: index. Physics2D.bindings.cs 2823 public void SetPath(....) { if (index < 0) throw new ArgumentOutOfRangeException( String.Format("Negative path index is invalid.", index)); .... } There is no error in code, but as the saying goes, the code "smells". Probably, an earlier message was more informative, like this: "Negative path index {0} is invalid.". Then it was simplified, but developers forgot to remove the parameter index for the method Format. Of course, this is not the same as a forgotten parameter for the indicated output string specifier, i.e. the construction of the type String.Format("Negative path index {0} is invalid."). In such a case, an exception would be thrown. But in our case we also need neatness when refactoring. The code has to be fixed as follows: public void SetPath(....) { if (index < 0) throw new ArgumentOutOfRangeException( "Negative path index is invalid."); .... } Substring of the substring PVS-Studio warning: V3053 An excessive expression. Examine the substrings 'UnityEngine.' and 'UnityEngine.SetupCoroutine'. StackTrace.cs 43 static bool IsSystemStacktraceType(object name) { string casted = (string)name; return casted.StartsWith("UnityEditor.") || casted.StartsWith("UnityEngine.") || casted.StartsWith("System.") || casted.StartsWith("UnityScript.Lang.") || casted.StartsWith("Boo.Lang.") || casted.StartsWith("UnityEngine.SetupCoroutine"); } Search of the substring "UnityEngine.SetupCoroutine" in the condition is meaningless, because before that the search for "UnityEngine." is performed. Therefore, the last check should be removed or one has to clarify the correctness of substrings. Another similar error: PVS-Studio warning: V3053 An excessive expression. Examine the substrings 'Windows.dll' and 'Windows.'. AssemblyHelper.cs 84 static private bool CouldBelongToDotNetOrWindowsRuntime(string assemblyPath) { return assemblyPath.IndexOf("mscorlib.dll") != -1 || assemblyPath.IndexOf("System.") != -1 || assemblyPath.IndexOf("Windows.dll") != -1 || // <= assemblyPath.IndexOf("Microsoft.") != -1 || assemblyPath.IndexOf("Windows.") != -1 || // <= assemblyPath.IndexOf("WinRTLegacy.dll") != -1 || assemblyPath.IndexOf("platform.dll") != -1; } Size does matter PVS-Studio warning: V3063 CWE-571 A part of conditional expression is always true if it is evaluated: pageSize <= 1000. UNETInterface.cs 584 public override bool IsValid() { .... return base.IsValid() && (pageSize >= 1 || pageSize <= 1000) && totalFilters <= 10; } Condition for a check of a valid page size is erroneous. Instead of the operator ||, one has to use &&. The corrected code: public override bool IsValid() { .... return base.IsValid() && (pageSize >= 1 && pageSize <= 1000) && totalFilters <= 10; } Possible division by zero PVS-Studio warning: V3064 CWE-369 Potential division by zero. Consider inspecting denominator '(float)(width - 1)'. ClothInspector.cs 249 Texture2D GenerateColorTexture(int width) { .... for (int i = 0; i < width; i++) colors[i] = GetGradientColor(i / (float)(width - 1)); .... } The problem may occur when passing the value width = 1 into the method. In the method, it is not checked anyway. The method GenerateColorTexture is called in the code just once with the parameter 100: void OnEnable() { if (s_ColorTexture == null) s_ColorTexture = GenerateColorTexture(100); .... } So, there is no error here so far. But, just in case, in the method GenerateColorTexture the possibility of transferring incorrect width value should be provided. Paradoxical check PVS-Studio warning: V3080 CWE-476 Possible null dereference. Consider inspecting 'm_Parent'. EditorWindow.cs 449 public void ShowPopup() { if (m_Parent == null) { .... Rect r = m_Parent.borderSize.Add(....); .... } } Probably, due to a typo, the execution of such code guarantees the use of the null reference m_Parent. The corrected code: public void ShowPopup() { if (m_Parent != null) { .... Rect r = m_Parent.borderSize.Add(....); .... } } The same error occurs later in the code: PVS-Studio warning: V3080 CWE-476 Possible null dereference. Consider inspecting 'm_Parent'. EditorWindow.cs 470 internal void ShowWithMode(ShowMode mode) { if (m_Parent == null) { .... Rect r = m_Parent.borderSize.Add(....); .... } And here's another interesting bug that can lead to access by a null reference due to incorrect check: PVS-Studio warning: V3080 CWE-476 Possible null dereference. Consider inspecting 'objects'. TypeSelectionList.cs 48 public TypeSelection(string typeName, Object[] objects) { System.Diagnostics.Debug.Assert(objects != null || objects.Length >= 1); .... } It seems to me that Unity developers quite often make errors related to misuse of operators || and && in conditions. In this case, if objects has a null value, then this will lead to a check of second part of the condition (objects != null || objects.Length >= 1), which will entail the unexpected throw of an exception. The error should be corrected as follows: public TypeSelection(string typeName, Object[] objects) { System.Diagnostics.Debug.Assert(objects != null && objects.Length >= 1); .... } Early nullifying PVS-Studio warning: V3080 CWE-476 Possible null dereference. Consider inspecting 'm_RowRects'. TreeViewControlGUI.cs 272 public override void GetFirstAndLastRowVisible(....) { .... if (rowCount != m_RowRects.Count) { m_RowRects = null; throw new InvalidOperationException(string.Format("....", rowCount, m_RowRects.Count)); } .... } In this case, the exception throw (access by the null reference m_RowRects) will happen when generating the message string for another exception. Code might be fixed, for example, as follows: public override void GetFirstAndLastRowVisible(....) { .... if (rowCount != m_RowRects.Count) { var m_RowRectsCount = m_RowRects.Count; m_RowRects = null; throw new InvalidOperationException(string.Format("....", rowCount, m_RowRectsCount)); } .... } One more error when checking PVS-Studio warning: V3080 CWE-476 Possible null dereference. Consider inspecting 'additionalOptions'. MonoCrossCompile.cs 279 static void CrossCompileAOT(....) { .... if (additionalOptions != null & additionalOptions.Trim().Length > 0) arguments += additionalOptions.Trim() + ","; .... } Due to the fact that the & operator is used in a condition, the second part of the condition will always be checked, regardless of the result of the check of the first part. In case if the variable additionalOptions has the null value, the exception throw is inevitable. The error has to be corrected, by using the operator && instead of &. As we can see, among the warnings with the number V3080 there are rather insidious errors. Late check PVS-Studio warning: V3095 CWE-476 The 'element' object was used before it was verified against null. Check lines: 101, 107. StyleContext.cs 101 public override void OnBeginElementTest(VisualElement element, ....) { if (element.IsDirty(ChangeType.Styles)) { .... } if (element != null && element.styleSheets != null) { .... } .... } The variable element is used without preliminary check for null. While later in the code this check is performed. The code probably needs to be corrected as follows: public override void OnBeginElementTest(VisualElement element, ....) { if (element != null) { if (element.IsDirty(ChangeType.Styles)) { .... } if (element.styleSheets != null) { .... } } .... } In code there are 18 more errors. Let me give you a list of the first 10: V3095 CWE-476 The 'property' object was used before it was verified against null. Check lines: 5137, 5154. EditorGUI.cs 5137 V3095 CWE-476 The 'exposedPropertyTable' object was used before it was verified against null. Check lines: 152, 154. ExposedReferenceDrawer.cs 152 V3095 CWE-476 The 'rectObjs' object was used before it was verified against null. Check lines: 97, 99. RectSelection.cs 97 V3095 CWE-476 The 'm_EditorCache' object was used before it was verified against null. Check lines: 134, 140. EditorCache.cs 134 V3095 CWE-476 The 'setup' object was used before it was verified against null. Check lines: 43, 47. TreeViewExpandAnimator.cs 43 V3095 CWE-476 The 'response.job' object was used before it was verified against null. Check lines: 88, 99. AssetStoreClient.cs 88 V3095 CWE-476 The 'compilationTask' object was used before it was verified against null. Check lines: 1010, 1011. EditorCompilation.cs 1010 V3095 CWE-476 The 'm_GenericPresetLibraryInspector' object was used before it was verified against null. Check lines: 35, 36. CurvePresetLibraryInspector.cs 35 V3095 CWE-476 The 'Event.current' object was used before it was verified against null. Check lines: 574, 620. AvatarMaskInspector.cs 574 V3095 CWE-476 The 'm_GenericPresetLibraryInspector' object was used before it was verified against null. Check lines: 31, 32. ColorPresetLibraryInspector.cs 31 Wrong Equals method PVS-Studio warning: V3115 CWE-684 Passing 'null' to 'Equals' method should not result in 'NullReferenceException'. CurveEditorSelection.cs 74 public override bool Equals(object _other) { CurveSelection other = (CurveSelection)_other; return other.curveID == curveID && other.key == key && other.type == type; } Overload of the Equals method was implemented carelessly. One has to take into account the possibility of obtaining null as a parameter, as this can lead to a throw of an exception, which hasn't been considered in the calling code. In addition, the situation, when _other can't be cast to the type CurveSelection, will lead to a throw of an exception. The code has to be fixed. A good example of the implementation of Object.equals overload is given in the documentation. In the code, there are other similar errors: V3115 CWE-684 Passing 'null' to 'Equals' method should not result in 'NullReferenceException'. SpritePackerWindow.cs 40 V3115 CWE-684 Passing 'null' to 'Equals' method should not result in 'NullReferenceException'. PlatformIconField.cs 28 V3115 CWE-684 Passing 'null' to 'Equals' method should not result in 'NullReferenceException'. ShapeEditor.cs 161 V3115 CWE-684 Passing 'null' to 'Equals' method should not result in 'NullReferenceException'. ActiveEditorTrackerBindings.gen.cs 33 V3115 CWE-684 Passing 'null' to 'Equals' method should not result in 'NullReferenceException'. ProfilerFrameDataView.bindings.cs 60 Once again about the check for null inequality PVS-Studio warning: V3125 CWE-476 The 'camera' object was used after it was verified against null. Check lines: 184, 180. ARBackgroundRenderer.cs 184 protected void DisableARBackgroundRendering() { .... if (camera != null) camera.clearFlags = m_CameraClearFlags; // Command buffer camera.RemoveCommandBuffer(CameraEvent.BeforeForwardOpaque, m_CommandBuffer); camera.RemoveCommandBuffer(CameraEvent.BeforeGBuffer, m_CommandBuffer); } When the camera variable is used the first time, it is checked for null inequality. But further along the code the developers forget to do it. The correct variant could be like this: protected void DisableARBackgroundRendering() { .... if (camera != null) { camera.clearFlags = m_CameraClearFlags; // Command buffer camera.RemoveCommandBuffer(CameraEvent.BeforeForwardOpaque, m_CommandBuffer); camera.RemoveCommandBuffer(CameraEvent.BeforeGBuffer, m_CommandBuffer); } } Another similar error: PVS-Studio warning: V3125 CWE-476 The 'item' object was used after it was verified against null. Check lines: 88, 85. TreeViewForAudioMixerGroups.cs 88 protected override Texture GetIconForItem(TreeViewItem item) { if (item != null && item.icon != null) return item.icon; if (item.id == kNoneItemID) // <= return k_AudioListenerIcon; return k_AudioGroupIcon; } An error, that in some cases leads to an access by a null link. The execution of the condition in the first block if enables the exit from the method. However, if this does not happen, then there is no guarantee that the reference item is non-zero. Here is the corrected version of the code: protected override Texture GetIconForItem(TreeViewItem item) { if (item != null) { if (item.icon != null) return item.icon; if (item.id == kNoneItemID) return k_AudioListenerIcon; } return k_AudioGroupIcon; } In the code there are 12 similar errors. Let me give you a list of the first 10: V3125 CWE-476 The 'element' object was used after it was verified against null. Check lines: 132, 107. StyleContext.cs 132 V3125 CWE-476 The 'mi.DeclaringType' object was used after it was verified against null. Check lines: 68, 49. AttributeHelper.cs 68 V3125 CWE-476 The 'label' object was used after it was verified against null. Check lines: 5016, 4999. EditorGUI.cs 5016 V3125 CWE-476 The 'Event.current' object was used after it was verified against null. Check lines: 277, 268. HostView.cs 277 V3125 CWE-476 The 'bpst' object was used after it was verified against null. Check lines: 96, 92. BuildPlayerSceneTreeView.cs 96 V3125 CWE-476 The 'state' object was used after it was verified against null. Check lines: 417, 404. EditorGUIExt.cs 417 V3125 CWE-476 The 'dock' object was used after it was verified against null. Check lines: 370, 365. WindowLayout.cs 370 V3125 CWE-476 The 'info' object was used after it was verified against null. Check lines: 234, 226. AssetStoreAssetInspector.cs 234 V3125 CWE-476 The 'platformProvider' object was used after it was verified against null. Check lines: 262, 222. CodeStrippingUtils.cs 262 V3125 CWE-476 The 'm_ControlPoints' object was used after it was verified against null. Check lines: 373, 361. EdgeControl.cs 373 The choice turned out to be small PVS-Studio warning: V3136 CWE-691 Constant expression in switch statement. HolographicEmulationWindow.cs 261 void ConnectionStateGUI() { .... HolographicStreamerConnectionState connectionState = PerceptionRemotingPlugin.GetConnectionState(); switch (connectionState) { .... } .... } The method PerceptionRemotingPlugin.GetConnectionState() is to blame here. We have already come across it when we were analyzing the warnings V3022: internal static HolographicStreamerConnectionState GetConnectionState() { return HolographicStreamerConnectionState.Disconnected; } The method will return a constant. This code is very strange. It needs to be paid attention. Conclusions I think we can stop at this point, otherwise the article will become boring and overextended. Again, I listed the errors that I just couldn't miss. Sure, the Unity code contains a big number of the erroneous and incorrect constructions, that need to be fixed. The difficulty is that many of the issued warnings are very controversial and only the author of the code is able to make the exact "diagnosis" in each case. Generally speaking about the Unity project, we can say that it is rich for errors, but taking into account the size of its code base (400 thousand lines), it's not so bad. Nevertheless, I hope that the authors will not neglect the code analysis tools to improve the quality of their product. Use PVS-Studio and I wish you bugless code!
  2. I feel like I should know this, but I tried looking it up to make sure I wasn't confusing myself, and couldn't seem to find a clear answer that made sense to me. When assigning something like this: GridSquare randomPosition; randomPosition = gridPositions[Random.Range(0,gridPositions.GetLength(0)),Random.Range(0,gridPositions.GetLength(1))]; Am I putting a copy of the GridSquare in gridPositions into the GridSquare randomPosition, or is randomPosition referencing the GridSquare at this location? If it's a copy, is there a way to reference it, like a pointer in c++, because that's what I want to do.
  3. I'm looking for people to collaborate with on a (small scoped) project of our choosing. I'm ideally looking for something that we can publish to an app store in under 6 months and then reassess the situation before deciding on next steps. I'm not terribly concerned about genre/art/2Dvs3D/platform/etc, I think it's more important to gather a group of like-minded individuals and then make those choices once we understand the skillset of the people involved. I want to treat this as a learning experience, a way to add another game to our CVs, and potentially as a way to meet people who can continue to collaborate in the future. Full Disclosure I've tried this in the past (using the similar Reddit forum) and gotten burned every time. Because of that, I want to make sure that I'm only collaborating with people who will be directly contributing to the product - art/sound/animation/development/etc. I'm not looking to work with people whose responsibilities are limited to entrepenuer/"idea man"/project management. About Me By day, I'm a Principal Software Architect at an enterprise software firm. I've been working in Software Development for around 15 years, mainly focusing on the Microsoft stack - C++, C#, .NET, WPF, databases and most recently with modern architecture (containers, Docker, REST APIs, RabbitMQ, etc etc). I have many years of Product Ownership, Project Management, and leading a dev team from an idea to a released product, so I can very comfortably "rein in" the scope of work, ensure we're driving towards an MVP, and make sure we're all on the same page about decisions we're making. By night, I'm a hobby Game Developer. I've been playing with game dev for years (like basically every person who gets into Software Dev) from DirectX 9 through XNA, GameMaker Studio, and the last 5 or so years have been in Unity3D. Feel free to browse my Github (https://github.com/natertots). I've "published" a couple very, very basic games by myself. Here's one: https://play.google.com/store/apps/details?id=com.NaterTots.Sloth . Don't get your hopes up. Being an architect by profession, I sometimes focus on spending too much time architecting the "perfect" solution to a problem. Case in point - I've spent the last couple weeks making a Data I/O layer to more easily create data objects that get serialized/deserialized generically from any of a number of locations (locally, web, save location). I have a strong programming background and feel comfortable implementing most any aspect of a game. About You A passionate contributor: art/sound/animation/development/etc. Experience level doesn't matter. I don't think we should try to enforce hours/time contribution, just as long as we're not stalling and continually making progress, even if it slows at times. Someone who's in it to learn and get better. We're not going to make the next PUBG or WoW. I don't even want to have the expectation that the focus of this project is to make money. A good communicator. I've had the best experience working with a combination of Slack and Trello. I'm in the EST time zone and will spend most of my working time around 8pm-midnight, so being available at some point during those times to chat would be a big plus. Willing to work in Unity 3D and (if a dev) program in C#. Sorry this is a narrow scope, but since I've focused so much effort on ramping up on this platform and language, I would rather not shift away from it. Note: I'm just looking for people "willing", not necessarily experienced. I look forward to working with you, Nate
  4. So i began on my first and frankly it is really simple i just want a box to jump up and onto the next platform above it. They problem is when i look up a tutorial they don't get me where i want it. I need to know how to make a moving platform from side to side and then when my play lands on it the platform will center in the middle of the screen and stop so i can keep jumping up to the next platform. I can already make my player jump i also know how to make one way floors so that is covered i just cant figure out the platform.
  5. Hello Readers! I had a great opportunity this past weekend to have some people play test the game. For the most part it went well…that is, until the frame rates dropped to a point of being unplayable, glitches caused the player to reset to random places on the map, and the controller seemed to invert itself through an act of black magic. The experience was very enlightening and served as a gentle reminder that making games is a TON of work and requires loads of dedication to see it through to the end. In the spirit of humility, I thought I would use today’s blog entry to discuss the lessons I learned, and how I intend to progress moving forward. I welcome any insights and comments, and I would love to hear about some of the lessons you've learned along the way. Lessons 1) Play test early and often with people other than yourself. 2) Profile early and often on the target devices. 3) Don’t leave highly problematic bugs and errors for later. 4) Don’t change the algorithm for essential game mechanics too late in development. 5) Keep lots of backups. 6) Learn from other's mistakes Play test early and often with people other than yourself This lesson was a hard one to learn. When the first level of the game was complete, I thought I could simply play test it myself and would get good feedback. This was true, but only to an extent. When I let other people play it, I quickly found out that the controls are confusing, the map doesn’t provide enough direction, and players will use the main character in ways I never even thought of. It would have been incredibly helpful to test the core mechanics on another person early on while I was developing them, rather than waiting until multiple levels have been made. As it stands, I’ve spent around 12 hours changing the controls on the hero’s climb animation so the mechanic feels more natural. Profile early and often on the target devices There were some serious frame rate drops going on that I didn’t realize because I was only testing the game on my home PC, which has a strong specs. When I put the game on my laptop, the frame rates dropped to the point of losing playability. I learned that profiling isn’t something that needs to wait till the end of development, and it would have been wise to profile as I built up the core mechanics. Using the profile after each new level or major game change and responding to its results is a great way to avoid these types of issues. Don’t leave highly problematic bugs and errors for later. It’s easy to become so fixated on finishing the game that errors and bugs are pushed off until a later time. I find, however, that engaging in this procrastination results in a ton of errors that compound on one another. For example, there was a problem with the hang animation, which caused a problem with the physics system, which caused a frame rate drop, etc. etc. Fixing these errors and bugs in order to build a strong foundation for the game mechanics is essential. Don’t change the algorithm for essential game mechanics too late in development In an attempt to fix the problems with my climb mechanic, I decided that the current algorithm had too many bugs to be salvageable. I spent a good number of hours creating a new algorithm that ended up failing miserably. The worst part is I screwed up the main characters script so much in the process that I had to revert to an earlier backup. After restoring the backup, I discovered a way to upgrade the mechanic as well as fix many of the bugs. Nothing is more heart breaking than losing hours of unnecessary work, which leads me to the final lesson. Keep lots of backups After every major change, make a backup. After every development session, make a backup. After every optimization, make a backup. The point is, keep lots of backups. I made the mistake of optimizing a lot of code and then trying to redo the algorithm for the climb mechanic. Had I made a backup AFTER the optimization, I wouldn’t have spent so much time redoing work. I know there are a lot of lessons left for me to learn. Learn from other's mistakes All these lessons bring me to my final point - Learn from other's mistakes. I do a good bit of reading about challenges other developers experience, but it is so easy to think "that won't happen to me." Humbling oneself and learning from another person's mistakes is wise, and I plan to listen to the advice of seasoned developers. Which brings me to my final question, what lessons have you learned about development along the way? _______________________________________________________________________________________ As always, thank you for reading. I would love to hear from you and would love to hear any comments or ideas you have. Feel free to leave a comment or email me at watermoongames@gmail.com. _________________________________________________________________________________________
  6. 13 RONIN

    13 RONIN 13 RONIN is a 2D pixel art samurai sword fighting game inspired by old japanese samurai movies and 8-bit classics such as Barbarian and The Way Of The Exploding Fist. Your mission as a noble samurai is to defeat 13 renegade ronin and their murderous leader. Although done in low resolution pixel art the game will have an somewhat “arty” aesthetic in black and white mixed with details in color. Who am I ? I’m a 40 year old Swede with about 17 years of professional experience working as a .Net developer. To make a game has been a dream ever since I as a child learned to write a “guess a number”-game on my Commodore 64. Now I’m trying to fulfill that dream. I’m the sole developer behind this project and I’m doing it as an sparetime project so please be patient. Status The main structure of the game and basic gameplay, based on placeholder graphics, is done and I’m currently switching between drawing assets and coding graphic effects like rain and lightning. News I’m quit often updating my dev blog with short posts about the progress I make. A post can contain a new animation, a sound effect, a code sample or something else related to the making of 13 RONIN. On this and other forums I will post updates, that are longer than those on my site, but not as often. To help and inspire the community I will share tools and parts of the code on my BitBucket-page. Goals My current goal is to get a demo finished and released. The demo will only contain 1 or maybe 2 different opponents but otherwise be a fully playable game. This version will be absolutely free. The full game will contain 13 levels, all with different enemies, backgrounds and background animations. This version will be priced as other games of similar scope. Currently I’m aiming for a PC release but other platforms might follow. Happy coding! /jan. https://www.eraserheadstudio.com/
  7. I've got a problem with a piece of code and I'm not sure if I just have the syntax wrong or if I am doing something fundamentally wrong. Here is the line of code: currentPosition = gridPositions[randomIndex].Id; basically what's happening here is currentPosition is an int, gridPositions is a list of a custom class called GridSquare. Each GridSquare object contains a Vector3, a bool, and an int. the Int is Id. I'm trying to assign the Id int to the int currentPosition. What I'm getting instead is the index of gridPositions that we are currently on. Any ideas on why that would be, and if so how I can assign Id to currentPosition?
  8. I am currently making a RPG game for my oop class project using visual studio windows form c#, i have a class for the stage containing picture(stage image), sound(bg sound), status(clear/or not clear), name(stage name) i want to generate the stage like this, should i create it using a method and generate it at the class constructor or is there a better way to achive what i want? the one i want to generate is the blue dot and the yellow square, i created the other manually in the form
  9. I am trying to make a RPG game for my college oop class project using windows form, i am having trouble in moving the character,when i click the go button i want my player(black picbox) to move to the first big gray picbox and so on but before the player reach the big one i want the player to move to the small one first then stop at the big one, i am using timer to achieve that but i m having trouble, this is the code that i write in the timer_tick event (Moderator edit: attempted to format code -- Kylotan) for(int i = 0; i < stoneL.Count; i++) { x++; for(int j = 0; j < stoneS.Count; j++) { if (x % 2 != 0) { pictureBoxPlayer.Location = new Point(pictureBoxPlayer.Location.X, stoneS[j].Location.Y); } else { pictureBoxPlayer.Location = new Point(pictureBoxPlayer.Location.X, stoneL.Location.Y); timer1.Enabled = false; } if(j == x) { break; } } break; } i am having trouble in the outer loop, its says that the i++ code is unreachable i try to find out why but i am still stuck in this part, can someone please help solve this problem or any advice how to achieve what i want with a better code?i appreciate any kind of help, sorry if my explanation is kindda messy
  10. I've been thinking a lot about how I want to approach the design for interactive objects in my 2D Platformer. I wanted to do something lightweight and centralised so I started work on an Event Class that embodied anything that would be interacted with. The type of interaction would be defined in the Unity Editor though a Custom GUI that I am working on. As you can see, this "event" would be for a moving platform. If "Is Triggered" is ticked, the Platform moves only when the player jumps onto it and activates it. Otherwise it will interpolate between the definable "Start Position" and "End Position". Depending on which "Event" (enum) is selected, the Editor properties will change and so will the behaviour of the Game Object with the event attached to it. For example, selecting "Item Collect" would mean that the Game Object is no longer a platform - no longer an object that moves when activated - it would be a stationary sprite that, when activated, would disappear and add itself into the player Inventory. Here's some code to show where I'm at with it: /* * ############################# * ##@@## INITIALIZATION ##@@## * ############################# * */ private void Awake() { SetupEvent(eventType); } public void Activate(bool calledFromTrigger = false) { if (autoTrigger && !calledFromTrigger) return; Debug.Log("Activated " + name + "!"); StartEvent(eventType); } private void StartEvent(EventType type) { switch (type) { case EventType.Movement: MovePlatform(); break; case EventType.Dialogue: break; case EventType.NPC: break; case EventType.ItemCollect: break; case EventType.Cutscene: break; case EventType.Switch: break; case EventType.Custom: break; } Don't be deceived by the snippet - this is all quite functional as of right now, but I can't help but feel I am making a mistake. I keep having this gut wrenching feeling pulling me to scrap it and rewrite the "Event" class to be a base class of "Interactible" and for each type, or what is currently an enum, to be a child of Interactible. Essentially, I am not sure whether to base my events off of one Event class, with functionality dependent on the selected "Event Type" enum... Or have the "Event Types" span multiple classes inheriting from a base "Interactible" class. I like to be able to just drag and drop, select what I want all in one place - but I feel that this is entirely impractical due to its low level of abstraction and code being all in one spot. Can I get some opinions? I am a relatively beginner programmer but I know code decent enough to be able to use more advanced techniques I think. Here is a screenshot of my game for context.
  11. I've got an error on this line of code: currentPosition = gridPositions[randomPosition].Id; The error says "The bets overloaded method math for 'System.Collections.Generic.List<GridSquare>.this[int]' has some invalid arguments" I'm not entirely sure what this means, but to explain what I'm doing here, I've got currentPosition which is an int, and gridPositions is a list of GridSquares (a custom class that contains a Vector3, a bool, and an int). Id is the int property on GridSquares. I'm trying to assign the Id to currentPosition but I'm getting this error. I thought that this should work so I'm not sure what I'm missing here. Literally as soon as I post this I find what I did wrong. lol. I had randomPosition in there, not randomIndex. randomPosition is a Vector3. Oops!
  12. Handling collision

    Hi , I've been working on some on a game server in Unity. And I was wondering how I should handling collision detection. I'm using TCP at the moment. I thought I'd write a custom tool , that would find all objects in the game scene. And push that to a file. And let the Server read it out. So it know's where are collision objects are. Not sure if this is the best approach. I also wonderd how to handle character movement correctly. My client sends each 100ms a update of he's position (if they moved). The server sends each 150ms to all clients all positions. But I want to check if there are players in he's area. But that would be again a lot of calculations for the server. https://gyazo.com/d233ca0b4673a00eb62331603281cdf9
  13. Hello all! Welcome to this week’s edition of the Untouched Earth development blog. I had a semi productive week, which is great considering I had family visiting and various other things that required my attention. One of the things I love about indie game development is the flexibility it provides in terms of production. However, that doesn’t mean producing a game is without short and long term goals. I recently set the goal that I will complete one level every two weeks until I’ve completed 12 total levels. It’s really helped keep me on track doing updates on a daily basis. Which brings me to my next point, this week’s updates! Updates this week include: Continued developing level three (about 75% complete) *Spotlight* Fixed a bug causing the player to jump endlessly when performing air combat *Spotlight* Obtained logos for the game *Spotlight* Added new coins to the game Play tested levels one and two and fixed errors with world rendering and enemy behavior Added NPC’s who help the hero on his journey Fixed a bug that prevented bullets from causing damage to enemies Fixed a bug that inhibited the hero’s ability to land on certain terrain *Spotlight* Created a falling bridge obstacle Updated input manager to allow keyboard input for basic actions _________________________________________________________________________________________ Spotlight 1: Fixed a bug causing the player to jump endlessly from air combat I had this terrible bug pop up out of nowhere that allowed the hero to jump in midair as many times as he wanted when I pressed one of the combat buttons. This bug obviously allowed the hero to be more of a superhero, and had to go. It only took about 30 minutes to figure out what was going on, and I believe I have the bug ironed out. It turns out I caused the error when I gave the hero the ability to transition to his jumping animation from any air combat animation. Once I removed this code, it worked just fine. _________________________________________________________________________________________ Spotlight 2: Obtained logos for the game I love these logos! They looks fantastic! Every time I see them I feel like there’s adventure on the way and danger to be dodged. They were created by Jacob Garren, and really bring the adventure to life. Thank you Jacob for making great logos! _________________________________________________________________________________________ Spotlight 3: Added new coins to the game The coins I was using in the game looked a little out of place. They were bright colors and looked like they belong in a children’s toy chest rather than an exciting and adventurous 2D jungle game! I decided to investigate other options, and came across a great set of coins in the unity asset store (thank you Rexard for making great assets). I didn’t alter the coins in any way except for changing the colors. They look fantastic! While the implementation was relatively straight forward (drag and drop the new sprite into the sprite renderer) I did, however, struggle with a clean switch from the old coins to the new ones. For some reason, many of the coins didn’t resize correctly and weren’t responding to a prefab alteration. I had to go back over all of the old coins and reset their size. It wasn’t one of the more glamorous parts of game development, but it was necessary. Luckily these new ones look so fantastic that I harbor no resentments. _________________________________________________________________________________________ Spotlight 4: Created a falling bridge obstacle The hero often goes over bridges as he moves from piece of terrain to the next. I thought it might be fun to have the floor unexpectedly fall out from underneath him (sick and twisted, I know). It turns out it is fun so long as the hero doesn't plummet to his death too often. It’s a relatively simple obstacle developed with the animator and a small script. _________________________________________________________________________________________ As always, thank you for reading. I would love to hear from you and would love to hear any comments or ideas you have. Feel free to leave a comment or email me at watermoongames@gmail.com. _________________________________________________________________________________________
  14. Developing 2D sports game

    Hi everyone, My main goal is to eventually build an extremely simple (graphics-wise/game-physics wise) sports video game in 2D. I am a big fan of the "old-skool" Genesis sports video games. I know some Python and C# but would really like to begin learning C++ as well. Where I am now: - My original thought was to continue learning some more C# and C++ before diving into any engine. I am thinking Udemy to take additional courses. -Perhaps, a tennis or golf game since I do not have to do deal with team-based AI which I have heard is extremely tricky to replicate. -Not sure, if Unity or Unreal is suited for sports game development? If one is better than better for 2-D based games, but I definitely want to learn both C# and C++. -Is it a realistic goal, to build a simple sports game (basic graphics and physics-- think Genesis or even early 90s DOS)? This goal is just for myself, I am not looking to make money off of this game but just some self-satisfaction that I can build it. Lastly, I know enough programming to build ROM editing tools in C# but that is the extent of my programming, with the exception of some simple Python scripting. I would appreciate anyone's input and thanks for taking to time to read this and/or respond. Thanks, DK
  15. So, I created a grid using a list. No problem. However, when it comes to manipulating the grid the way I need it's become a bit of a hassle and i'm looking for opinions on the best way to handle this. Here are my requirements for my grid: 1. Layout a grid that is 20W X 30H, however the screen will only display 20W X 15H. 2. We will be spawning bricks, but I only want them to spawn off screen. I've figured out how to do that, but if I change the structure, it's important that I retain that ability. 3. The first brick will spawn anywhere in the offscreen section of the grid. After that, each brick will spawn so that it has at least one adjacent brick that it is touching. 4. When a brick spawns, I need to somehow remove that grid space from the list of available brick spaces so that it doesn't try to put 2 bricks in the same location. 3 and 4 are the ones I'm having trouble with. I started working with just a list and had bricks spawning off screen the way I wanted but they were simply scattered. The problem with the list is that when I spawn a brick, i simply remove that entry from the list. Well then I have nothing to check against to see if there are any adjacent bricks. Someone suggested using a 2D array because it would be more efficient than a list and easier to check if bricks were touching. I had another person suggest using 2 lists and 2 2-dimensional arrays to cover all bases, but this seems a bit heavy handed to me. I also had a friend suggest using hash tables, which I have not used before, but after reading about them they also seem like a viable answer. I'm just wondering if anyone has any ideas or suggestions on the best way to keep this as lightweight as possible while still getting the work done. Thanks!
  16. CPU Raytracer

    I wanted to show my WIP CPU raytracer. I probably won't implement too many more features. I just want something that looks decent with a little GI and AO and a few dynamic lights and textures. The video is rendered at 160x90 and captured at 320x180. It runs around 20fps on one thread on an i3-6320. Not sure if that is slow or fast for what I have. I plan on making an attempt to add multi-threading. I can't use SIMD since this was made in Unity. At least I don't think there is support for it. I'm making it in Unity so making games is easier since I won't have to make a whole engine. https://www.youtube.com/watch?v=iL8z04nZ0J8 EDIT: I'm gonna post all future updates here. New video with improved frame-rate and overall better looking than the original. https://youtu.be/tXWXOWXnU50 Sorry about the image quality... YouTube took a dump on it. I had to forget the idea of using SIMD since using .Net 4.6 breaks the raycasting against complex mesh colliders. Still need to work on the aliasing. Color absorb values seem off. I think ambient occlusion is show better here, but dark box edges are back. I just gotta send transform values to my filter to brighten them. https://imgur.com/rajEQky Better AO example: https://imgur.com/gNPIjNM Unfortunately, I think the only way I'm gonna get this to run at higher resolutions with playable frame rates is by moving it to the GPU since I can't thread my trace code using Unity. EDIT: 4/13/2018 - I'm wondering if I can use Embree to make a library that I can call from within Unity. Should be faster than Unity's ray-cast. Anyway here's a new vid with some bouncing balls. I only do GI/AO every other pixel now so they have a little reduced effect... also increased contrast. I'm now blurring the whole render which makes it a little fuzzy. if I don't, there's flickering around object edges when moving around. Video is at 160x88. https://youtu.be/_OC3_BwELzk 4/15/2018 - Using a small amount of help from the GPU I was able to make it higher resolution, but from the crap youtube compression it still looks low rez so here are some screens too..This was rendered at 1080p and captured at half that. Trying to figure out a solution for shadows fading out at distances larger than a few meters. High Res AO Example-https://imgur.com/2nKISzW High Res GI Example-https://imgur.com/1oe4BFd
  17. Let me preface this by saying that I am not familiar with 3d modeling at all. In fact I know almost nothing about it. This is perhaps why I've decided to write my own 3D model format and my own 3D modeling software from scratch (I didn't want to deal with existing formats, which seemed quite complex for what I wanted to do) . Now my 3D modeling software is quite adequate for small things, but it's really slow to use and unfit for organic shapes. My 3D model format is very simple; -25,4.48,-25:251,252,250 -24,4.58,-25:250,253,250 -25,4.62,-24:250,252,251 -24,4.58,-25:250,253,250 -24,4.62,-24:250,253,251 -25,4.62,-24:250,252,251 -25,4.62,-24:250,252,251 -24,4.62,-24:250,253,251 ... It's broken in 2 part, the first 3 numbers (separated by ',') are floating point values representing the location of a vertex and the last 3 numbers represents the RGB value of the color of that vertex. Triangles are simply drawn by taking the first 3 vertex, then the next 3, etc till the whole list is drawn. Of course once loaded this data takes the form of a model class, which is a list of instances of a small vertex class. As you can imagine, this is probably the simplest way to store a model that contains "textures" (which I use loosely), but is good enough for my game. I've looked at several model format but mine seems quite unique at what it does. Is there anything like it out there? I would like to write a small converter to take models made with more competent 3D software and use them in my engine. Another option would be to write a plugin for an existing 3D modeling software, but I am unsure on how I would go about that since I have almost no experience with them. Could anyone point me in the right direction? At first it seemed like a reasonably simple thing to do but the more I investigate the question the more I think I'll just have to spend a few days fleshing out my own 3D modeling software.
  18. C# Career advice

    Hi, Im studying Videogame Design and Development (we use Unity) and my goal is to become a videogame programmer. Those are a very generalist studies so we doesnt deepen so much on advanced programming. I have previous (non engineer) programming certification, so I can build easily almost any prototype I design. But after a couple of years working with Unity I almost left completly aside things like OOP, MVC... So my first doubt is if I am in the wrong way. I know that I would be able to learn anything forgotten or new when I arrived at a new job. But will I even have this opportunity if there is nothing like that on my portfolio? (Because I think I have to show the code) If answer is that I need to deepen on those programming techniques, could you suggest any book or whatever that explains the need of those approaches on Unity and teach about them? On the other hand, do you think I can build my portfolio with prototypes? Just placeholders cubes and capsules... Because I really feel like Im loosing my time modelling or rigging for a programming portfolio. I mean, I cant reach the modelling level of a full-time modeller, so on my old trys, I think my demos even look worse (bad rig and things like that) than with just placeholders. Maybe employers doesnt even look at demos and only want finished and published games? Thats all, sorry about my bad english ^ Thanks.
  19. Hey everyone, ive used tools like Intel GPA in the past and I would like to continue doing that. But in my current work environment I cant find a tool that can analyze rendering without a swapchain and calling Present(). In addition to that, the program Im working on uses WPF for UI, which uses a D3D9Ex Device and some tools attach to that device instead. So, are there any tools that allow debugging D3D11 without depending on a swapchain? Thanks for any help!
  20. We're looking for a Unity (C#) Programmer for our 2D Project. We're looking for a new lead programmer to continue with an existing project. Project is an open-world RTS, and is very close to a prototyping (playable) phase. Our existing lead, unfortunately, has no more time for the project, and thus we are in search of a new one who is interested. Game is purely fantasy based, and we'll be able to give you much more detailed info about the project as we begin to work you into it. You'll be working with our junior dev, who has been here since the beginning. Primary skills needed are working within Unity. And skills with XML within Unity. Our list of major goals we'd need you to do is minimal, yet still fairly extensive: -Implement an already created pathfinding system (from the Unity Asset Store) to replace our existing pathfinding system. -Work with an existing random-node-web generator to act as our 'global map', interworking our random map generator to use the node creator as its respective 'world map' (this one is the most extensive, and we'll need to discuss it quite thoroughly before having you start with it- our junior dev is the one who created the node system, so he'll be able to assist you with the integration phase). -Work with an existing random-spawner to spawn desired objects across our map (desired objects change based on what map within the world this map is, so we'll need to discuss it more, but its not as extensive as interworking the random node generator). -Integrating our dual-map system that runs a static map (acting as player's home base, static, never changing) alongside the exploring map (which is dynamic, and changes quite often). This is relatively implemented already, but we'll need to mess with it further still. -Work with an existing XML database to implement it into the project. There's no integration yet, so it'll need to be from the ground up. But we have the database setup and ready to work with. -Content-implementation (after all else is done, this is to take care of anything that needs to be 'hard-coded', ie unique spell effects, etc- nothing too crazy) -Various performance enhancements (like setting up a simple easy-on-performance enabler/disabler to hide objects to save on performance... and other things we'll need to discuss- again, nothing too crazy). -Implementing a simple menu system, alongside an adequate saving system (saving system will be similar to Skyrim). But we'll also need to ensure saving a considerable amount of extra things- from Map Exploration, to World Exploration, to hotbar setups, to all the misc data like units, location, resources, and so forth. Let me know your rates per hour, and we'll see if we can work out a good deal between both of us. Royalties are implied. If you feel you'd be able to accomplish all of the above, then we'd definitely like to work with you. Obviously- we won't know how to implement everything until we get to the physical code. But just making sure you know of this ahead of time so you know exactly what you'd be getting into is much more beneficial for both of us. If interested, send an email to: eldwin11929@yahoo.com Thanks!
  21. COMPANY AND THE PROJECT We are an indie game studio consisted of professional and skilled artists who are dedicated indie enthusiasts. Our current project is INT, developed on Unity Engine 5 for platforms Windows, Linux, and Mac. We are recruiting a few more members on the team to finalize our playable demo. INT is a 3D Sci-fi RPG with a strong emphasis on story, role playing, and innovative RPG features such as randomized companions. The focus is on the journey through a war-torn world with fast-paced combat against hordes of enemies. The player must accomplish quests like a traditional RPG, complete objectives, and meet lively crew members who will aid in the player's survival. Throughout the game you can side and complete missions through criminal cartels, and the two major combatants, the UCE and ACP, of the Interstellar Civil War. Please note that all of our current positions are remote work. You will not be required to travel. For more information about us, follow the links listed below. INT Official website Steam Greenlight IndieDB page Also follow social media platforms for the latest news regarding our projects. Facebook Twitter UNITY ENGINE PROGRAMMER We are looking for Unity Programmers. You will be working with our Coding team Lead to implement systems and mechanics using C# language. Your duties will include: Attendance of regular team meetings. Timely completion of implementation of assets. Direct contact with Project Lead and other Department Leads for the implementation process. Utilization of version control suites. Utilization of our project management boards (Trello) and communication channels to obtain up-to-date assets. REQUIREMENTS To be successful in this position, following requirements apply: Clear communication and self starter - pushes to meet deadlines and contribute to the project. Ability to complete tasks with limited input/direction from management. Comfortable with working with people remotely and via Trello management system. Good internet connection with ability to update assets/builds quickly, with large dependencies. At least 15 hours of availability each week. Proficient experience using the Unity Game Engine. Proficient experience in implementing assets into the Unity Game Engine. REVENUE - SHARE This is a great opportunity to get into the game development industry. We have the majority of our art assets completed and are marching towards our crowd-funding campaign, currently planned for mid 2018. We are unable to offer wages or per-item payments at this time. However revenue-sharing from crowd-funding is offered to team members who contribute 15-20 hours per week to company projects, as well as maintain constant communication and adhere to deadlines. Your understanding is dearly appreciated. TO APPLY Please send your Cover Letter, CV, Portfolio (if applicable), and other relevant documents/information to this email: JohnHR@int-game.net Thank you for your time! Please feel free to contact me via the email provided should you have any questions. We look forward to hearing from you! John Shen HR Lead Starboard Games LLC
  22. I've got a brick breaker game that procedurally generates bricks in random locations. I have it narrowed down to the columns and rows that I want them to spawn in. However, I don't want a bunch of disjointed bricks everywhere. I want them to all be connected. I don't care too much about the general layout, as long as they are all touching when they spawn. How can I do this? Is there a way that I can make sure as each one spawns, it spawns touching one of the previously spawned ones? I have attached the code for the board manager for anyone who wants to see what I'm working with. Thanks! private int columns = 20; //Number of columns in our game board. private int rows = 30; //Number of rows in our game board. public int brickCount; //Number of bricks to spawn. //Define brick types to assign sprites to in editor public GameObject oneHitBrick; public GameObject twoHitBrick; public GameObject threeHitBrick; public GameObject explodingBarrel; //temporarily represented by the unbreakable brick private Transform boardHolder; //A variable to store a reference to the transform of our Board object. private List <Vector3> gridPositions = new List <Vector3> (); //A list of possible locations to place tiles. //Clears our list gridPositions and prepares it to generate a new board. void InitialiseList () { //Clear our list gridPositions. gridPositions.Clear (); //Loop through x axis (columns). for(int x = 1; x < columns-1; x++) { //Within each column, loop through y axis (rows). for(int y = 22; y < rows-1; y++) { //At each index add a new Vector3 to our list with the x and y coordinates of that position. gridPositions.Add (new Vector3(x, y, 0f)); } } } //RandomPosition returns a random position from our list gridPositions. Vector3 RandomPosition () { //Declare an integer randomIndex, set it's value to a random number between 0 and the count of items in our List gridPositions. int randomIndex = Random.Range (1, gridPositions.Count); //Declare a variable of type Vector3 called randomPosition, set it's value to the entry at randomIndex from our List gridPositions. Vector3 randomPosition = gridPositions [randomIndex]; //Remove the entry at randomIndex from the list so that it can't be re-used. gridPositions.RemoveAt (randomIndex); //Return the randomly selected Vector3 position. return randomPosition; } //LayoutObjectAtRandom accepts an array of game objects to choose from along with a minimum and maximum range for the number of objects to create. void LayoutObjectAtRandom (GameObject brick, int brickCount) { //Instantiate objects until the randomly chosen limit objectCount is reached for(int i = 0; i < brickCount; i++) { //Choose a position for randomPosition by getting a random position from our list of available Vector3s stored in gridPosition Vector3 randomPosition = RandomPosition(); //Instantiate tileChoice at the position returned by RandomPosition with no change in rotation Instantiate(brick, randomPosition, Quaternion.identity); } } //SetupScene initializes our level and calls the previous functions to lay out the game board public void SetupScene (int level) { //Creates the outer walls and floor. //BoardSetup (); //Reset our list of gridpositions. InitialiseList (); brickCount = (int)Mathf.Log(level, 2f); //set the number of bricks based on the current level //Instantiate a random number of wall tiles based on minimum and maximum, at randomized positions. LayoutObjectAtRandom (oneHitBrick, brickCount); //Instantiate a random number of food tiles based on minimum and maximum, at randomized positions. LayoutObjectAtRandom (twoHitBrick, brickCount); LayoutObjectAtRandom (threeHitBrick, brickCount); }
  23. public int columns = 20; //Number of columns in our game board. public int rows = 30; //Number of rows in our game board. public int brickCount; //Number of bricks to spawn. //Define brick types to assign sprites to in editor public GameObject oneHitBrick; public GameObject twoHitBrick; public GameObject threeHitBrick; public GameObject explodingBarrel; //temporarily represented by the unbreakable brick private Transform boardHolder; //A variable to store a reference to the transform of our Board object. private List <Vector3> gridPositions = new List <Vector3> (); //A list of possible locations to place tiles. //Clears our list gridPositions and prepares it to generate a new board. void InitialiseList () { //Clear our list gridPositions. gridPositions.Clear (); //Loop through x axis (columns). for(int x = 1; x < columns-1; x++) { //Within each column, loop through y axis (rows). for(int y = 22; y < rows-1; y++) { //At each index add a new Vector3 to our list with the x and y coordinates of that position. gridPositions.Add (new Vector3(x, y, 0f)); } } } //RandomPosition returns a random position from our list gridPositions. Vector3 RandomPosition () { //Declare an integer randomIndex, set it's value to a random number between 0 and the count of items in our List gridPositions. int randomIndex = Random.Range (0, gridPositions.Count); //Declare a variable of type Vector3 called randomPosition, set it's value to the entry at randomIndex from our List gridPositions. Vector3 randomPosition = gridPositions[randomIndex]; //Remove the entry at randomIndex from the list so that it can't be re-used. gridPositions.RemoveAt (randomIndex); //Return the randomly selected Vector3 position. return randomPosition; } //LayoutObjectAtRandom accepts an array of game objects to choose from along with a minimum and maximum range for the number of objects to create. void LayoutObjectAtRandom (GameObject brick, int brickCount) { //Instantiate objects until the randomly chosen limit objectCount is reached for(int i = 0; i < brickCount; i++) { //Choose a position for randomPosition by getting a random position from our list of available Vector3s stored in gridPosition Vector3 randomPosition = RandomPosition(); //Instantiate tileChoice at the position returned by RandomPosition with no change in rotation Instantiate(brick, randomPosition, Quaternion.identity); } } //SetupScene initializes our level and calls the previous functions to lay out the game board public void SetupScene (int level) { //Creates the outer walls and floor. //BoardSetup (); //Reset our list of gridpositions. InitialiseList (); brickCount = (int)Mathf.Log(level, 2f); //set the number of bricks based on the current level //Instantiate a random number of wall tiles based on minimum and maximum, at randomized positions. LayoutObjectAtRandom (oneHitBrick, brickCount); //Instantiate a random number of food tiles based on minimum and maximum, at randomized positions. LayoutObjectAtRandom (twoHitBrick, brickCount); LayoutObjectAtRandom (threeHitBrick, brickCount); } I am trying to create a variant of Arkanoid and Space Invaders. I want the bricks to spawn procedurally off screen in a random arrangement according to set requirements. Then they would start moving down screen line by line. I could ask a hundred questions about how to do this, but for now I just have one. How do I start them spawning off screen? Currently, my screen is 20W X 15H. My current algorithm to set up the grid positions is your typical nested for loops, iterating through x and y for columns and rows. I'm wondering if the best way to do this is to expand my rows to maybe 30, while keeping the columns the same so as to constrain them over top of the screen, but allowing them only to spawn between grid positions in the rows off screen. Then find a way to move them down screen one line at a time. Is this the best method for this? Thanks for the help. Edit: This is the code I currently have. I think I have what I was talking about set up correctly, however I'm getting an out of range exception. I believe it has to do with the randomIndex possibly being below the 15 height, but I'm not sure. And I'm not sure how to change it to fix it.
  24. I have a save/load function in my 3D engine which was working quite well in the past. I've just added terrains (which are very small, no more than 100 triangles big) but I can't get them trough my save/load pipeline. They're quite a bit larger than any single model I've had to deal with in the past. I have no problem loading the model in my engine, it takes less than a second, but I have a problem serializing it for my game save/load function which uses a different format than my model format. The whole terrain model file looks like this: -25,4.48,-25:251,252,250 -24,4.58,-25:250,253,250 -25,4.62,-24:250,252,251 -24,4.58,-25:250,253,250 -24,4.62,-24:250,253,251 -25,4.62,-24:250,252,251 -25,4.62,-24:250,252,251 -24,4.62,-24:250,253,251 ... but this is nearly irrelevant as my save function only serializes the string using : data += Serializebytes(Encoding.ASCII.GetBytes(entity.model.StringContent)); where Serializebytes() is : static string Serializebytes(byte[] bytes) { char byteSep = ' '; string byteString = ""; foreach (byte byten in bytes) { byteString += byten.ToString(); byteString += byteSep; } return (byteString); } The problem really is with my serialize bytes method, the program hangs there as it takes forever to process. This worked fine for the very small model that composed my previous scenes but does not for the terrain. The function is simply supposed to take the bytes given by Encoding.ASCII.GetByte() and put a space between them. I figure this is something that should be relatively fast, even with very large amount of data. The perfect solution would be a simple function that would replace Serializebytes(). Thanks in advance guys.
  25. Wow! Very productive week full of new opportunities, new items, and new bug fixes. I must say, development seems to be progressing wonderfully (fingers crossed I didn’t just jinx myself 😊). The game’s fun level continues to increase, and, to me, that’s the whole point of agonizing over the minute details of code and animation – to give others a fun experience. ***Original blog post can be found by clicking here*** Updates this week include: Continued developing level three (about 50% complete) Fixed the artificial intelligence and decision making on enemy characters *Spotlight* Created a “Spinning Wheel” obstacle *Spotlight* Created a “Springy Platform” obstacle *Spotlight* Created a “Smasher” obstacle *Spotlight* Created two new characters called “Howler 2” and “Piper” Started creating a new Booster – “Slow time” *Spotlight* Created and implemented a rendering algorithm to Frames Per Second. Fixed a bug causing enemy health decrementation to be inconsistent Fixed the code that caused the “Howler” enemy to freeze when landing Fixed an error causing bullets to instantly be destroyed and not collide with enemies _______________________________________________________________________________________________________________________________ Spotlight 1: Created a "Spinning Wheel" obstacle I’m in love with this obstacle! It’s incredibly fun and presents a tough challenge to the hero. I died multiple time when testing it, but the thrill of successfully maneuvering it was invigorating. Basically, the obstacle has six platforms the player can jump on. Each platform moves around a center point at a duration and intensity set by the code. The first challenge was getting the six platforms to rotate around the center in harmony. I tried to create a script to manage the movement, but it was a big failure (failure is okay though!). Ultimately I ended up attaching an animator component and just creating an animation in the unity editor. The wheel spins faster by simply increasing the animation speed – Simple...so I thought. The startDelay variable causes the animation to wait for a number of seconds before starting. The animation variable refers to the types of animation available - either an animation where the "Spinning Wheel" moves and pauses or an animation where the "Spinning Wheel" moves continuously. _______________________________________________________________________________________________________________________________ Here's where a big error came in. The hero was not staying put on the platforms. The platforms would rotate out from under him, and he would fall to his untimely death (brought a tear to my eye to see such potential wasted so unfairly). I ended up creating a script for each platform that determined whether or not the platform was touching the hero. If it was, the platform script adjusts the hero’s position to keep him on top of the platform. heroScript refers to the script attached to the hero. If the hero is colliding with the platform, the touchingHero variable is set to true. This variable then signals that a change in position each must be calculated (deltaPosX & deltaPosY) during the FixedUpdate(). This change in position is then added to the hero's transform to correct his position. _______________________________________________________________________________________________________________________________ It worked like a charm! The spinning wheel was complete, and I could set how fast it moved in the unity editor. I created two modes for it: pause and continuous. Pause mode (featured in the video below) puts a brief pause in between rotations, whereas continuous mode rotates without any breaks. _______________________________________________________________________________________________________________________________ Spotlight 2: Created a “Springy Platform” The springy platform was pretty simple to make, and only took about an hour or so of development time. I had never used the SpringJoint2D, so it took some trial and error to make the obstacle usable. I love how it turned out, though! The character can land on it and bounce, making it hard to keep his footing. It really presents a challenge to game play, but, just like the “Spinning Wheel”, feels great when you defeat it! Victory! _______________________________________________________________________________________________________________________________ Spotlight 3: Created a “Smasher” obstacle I had originally created a larger smasher obstacle that would plummet downward upon the hero and send shock waves of crushing force through his body! This obstacle is simply an adaptation of that obstacle, but gave me a few challenges. The obstacle is intended to be used when the hero is climbing down a rope or vine. However, if the hero falls from the rope or vine and lands on the “Smasher” he is unable to move and receives damage until he dies. I foresaw rage quitting if I didn’t fix this bug. I ended up updating the hero’s detection manager to include “Smashers” as elements the hero can move on. (see the detection manager section of the game mechanics section if you’re not familiar with the detection manager). _______________________________________________________________________________________________________________________________ Spotlight 4: Created two new characters called “Howler 2” and “Piper” Two new characters joined the world, and boy oh boy do they make my skin crawl. Creepy and scary with a hint of horror. One of the characters, who I uniquely named “Howler 2”, is an adaptation of the “Howler” Character – Thank you again HQ game assets for making great assets. I did some art work to make him spookier, and augmented his script to make him more lethal. He’s able to evade hero attacks, is bigger, stronger, and can leap further than the “Howler.” The other character is called “Piper.” He is a distance based character that fires bolts of energy at the hero and runs away when the hero gets close. He’s a real challenge, but a lot of fun to beat up. _______________________________________________________________________________________________________________________________ Spotlight 5: Created and implemented a rendering algorithm to increase game speed. This update was huge! HUGE! There was a very serious problem where the frames per second were absolutely horrible when playing the game on a solid gaming PC. I realized I simply had far too many game objects active at once. I did a little research into several topics including object pooling, and ultimately created an algorithm that sets certain sections of the map active and other sections of the map inactive. I created a “Render Trigger” game object, which is basically just a game object with a trigger component, and set them up across the entire world. You can find the entire code below. Super simple and super effective! The game looks stunning, fluid, and has crazy high FPS now. The sections that are active are loaded into the render array in the unity editor. The sections that are inactive are loaded into the sleep array. When the hero touches the trigger, the render game objects are set active and the sleep game objects are set inactive _______________________________________________________________________________________________________________________________ As always, thank you for reading. I would love to hear from you and would love to hear any comments or ideas you have. Feel free to leave a comment or email me at watermoongames@gmail.com. _______________________________________________________________________________________________________________________________ ***Original blog post can be found by clicking here*** ***Visit Untouched Earth website for more details***
  • Advertisement