jeffrey.morris Posted December 7, 2020 Share Posted December 7, 2020 I tried to watch the boring 2-1/2 hour "movie" on creating a drivable vehicle. I need written step-by-step tutorial on creating a drivable vehicle. I have been using Unity3D and Unreal game engines. Please write step-by-step tutorial on creating a drivable vehicle. Link to comment
fox Posted December 8, 2020 Share Posted December 8, 2020 Hi Jeffrey, We're currently working on a text-based version of a Vehicle tutorial (using C# Components). Meanwhile, you can check out a simple Usage Example Creating a Car with Wheel Joints. Thanks for the feedback! Link to comment
jeffrey.morris Posted December 8, 2020 Author Share Posted December 8, 2020 I tried to follow the tutorial at https://developer.unigine.com/en/docs/code/usage/car_wheel_joints/index but I don't know how to create C++ files within Unigine project. Link to comment
fox Posted December 8, 2020 Share Posted December 8, 2020 If you prefer C#, there is a version for C# as well https://developer.unigine.com/en/docs/2.13/code/usage/car_wheel_joints/index?rlang=cs Simply switch the programming language here: But if you want to learn the C++ way, this article with a video quick tip might be useful. Hope this helps! Link to comment
jeffrey.morris Posted December 8, 2020 Author Share Posted December 8, 2020 (edited) Where is the AppWorldLogic.cs file? How can I fix this? D:\Unigine SDK Browser\projects\game01\game01.csproj : error : The SDK 'Microsoft.NET.Sdk' specified could not be found. D:\Unigine SDK Browser\projects\game01\game01.csproj Edited December 8, 2020 by jeffrey.morris Link to comment
mark.pizzolatto Posted December 8, 2020 Share Posted December 8, 2020 Greetings, Just verifying - you made a C# project and not just trying to convert a C++ project to a C# project? Link to comment
jeffrey.morris Posted December 8, 2020 Author Share Posted December 8, 2020 Mark, I created a new C# project. Link to comment
mark.pizzolatto Posted December 8, 2020 Share Posted December 8, 2020 (edited) Okay, not sure where the error is coming from. What editor/compiler are you using (and if possible provide some/all of the steps up to the error?) As for where to find the AppWorldLogic.cs, navigate to your projects directory (from the error you posted looks like: D:\Unigine SDK Browser\projects\game01), there should be a folder called "source" you should find all the pre-generated code files in there (main, AppWorldLogic, AppSystemLogic, and AppEditorLogic). Edited December 8, 2020 by mark.pizzolatto Link to comment
jeffrey.morris Posted December 9, 2020 Author Share Posted December 9, 2020 If I create the project using UnigineScript, the project worked. I tried to create the project using C# (.NET Core) but the build failed. This is driving me crazy! Microsoft (R) Build Engine version 16.7.1+52cd83677 for .NET Copyright (C) Microsoft Corporation. All rights reserved. source\AppWorldLogic.cs(14,3): error CS0246: The type or namespace name 'Car' could not be found (are you missing a using directive or an assembly reference?) [D:\Unigine SDK Browser\projects\game02\game02.csproj] Build FAILED. source\AppWorldLogic.cs(14,3): error CS0246: The type or namespace name 'Car' could not be found (are you missing a using directive or an assembly reference?) [D:\Unigine SDK Browser\projects\game02\game02.csproj] 0 Warning(s) 1 Error(s) Time Elapsed 00:00:00.76 AppWorldLogic.cs car.cs Link to comment
fox Posted December 9, 2020 Share Posted December 9, 2020 Hi Jeffrey! Seems like the error is caused by a typo in your car.cs file. Try replacing the line: public class car : Component With the following one: public class Car : Component Try re-compiling your project, this should remove the error. Hope this helps! Link to comment
jeffrey.morris Posted December 9, 2020 Author Share Posted December 9, 2020 Microsoft (R) Build Engine version 16.7.1+52cd83677 for .NET Copyright (C) Microsoft Corporation. All rights reserved. Determining projects to restore... All projects are up-to-date for restore. source\AppWorldLogic.cs(35,8): error CS0122: 'Car.Init()' is inaccessible due to its protection level [D:\Unigine SDK Browser\projects\game02\game02.csproj] source\AppWorldLogic.cs(44,8): error CS0122: 'Car.Update()' is inaccessible due to its protection level [D:\Unigine SDK Browser\projects\game02\game02.csproj] source\AppWorldLogic.cs(52,8): error CS1061: 'Car' does not contain a definition for 'UpdatePhysics' and no accessible extension method 'UpdatePhysics' accepting a first argument of type 'Car' could be found (are you missing a using directive or an assembly reference?) [D:\Unigine SDK Browser\projects\game02\game02.csproj] Build FAILED. source\AppWorldLogic.cs(35,8): error CS0122: 'Car.Init()' is inaccessible due to its protection level [D:\Unigine SDK Browser\projects\game02\game02.csproj] source\AppWorldLogic.cs(44,8): error CS0122: 'Car.Update()' is inaccessible due to its protection level [D:\Unigine SDK Browser\projects\game02\game02.csproj] source\AppWorldLogic.cs(52,8): error CS1061: 'Car' does not contain a definition for 'UpdatePhysics' and no accessible extension method 'UpdatePhysics' accepting a first argument of type 'Car' could be found (are you missing a using directive or an assembly reference?) [D:\Unigine SDK Browser\projects\game02\game02.csproj] 0 Warning(s) 3 Error(s) Time Elapsed 00:00:02.22 Link to comment
mark.pizzolatto Posted December 10, 2020 Share Posted December 10, 2020 (edited) Is the Car class being used that is causing those errors the same one you linked? is inaccessible due to its protection level -- This I believe is the hint, if I am not mistaken check the functions you are trying to access. With this error I believe (C# is not my primary language), its because your functions are currently 'private' to fix it change it to 'public' does not contain a definition for 'UpdatePhysics' -- as for this error, I believe that its saying there is no function with that name. I would test it - BUT, for some reason my compiler refuses to run C# code. Edited December 10, 2020 by mark.pizzolatto Link to comment
jeffrey.morris Posted December 10, 2020 Author Share Posted December 10, 2020 source\AppWorldLogic.cs(35,50): error CS1503: Argument 7: cannot convert from 'Unigine.dmat4' to 'Unigine.mat4' [D:\Unigine SDK Browser\projects\game02\game02.csproj] car.Init(4.0f, 2.0f, 0.5f, 0.5f, 0.5f, 25.0f, MathLib.Translate(new dvec3(0.0f, 0.0f, 1.0f))); I think that something is wrong with MathLib.Translate code. I just copied and pasted the code from Creating a Car with Wheel Joints - Documentation - Unigine Developer to Visual Studio Code software. Link to comment
mark.pizzolatto Posted December 10, 2020 Share Posted December 10, 2020 (edited) the init function parameters should look like: (it stopped giving me errors: public void Init(float a, float b, float c, float d, float e, float f, dmat4 g){} note - replace the letter with whatever name you had for it, this is just an example. Edit - just pulled up the code, I think it MIGHT be due to you having new dvec3(0.0f, 0.0f, 1.0f) - that d stands for double, try changing it to: new vec3(0.0f, 0.0f, 1.0f) -- then mat4 should work (or Mat4) Edited December 10, 2020 by mark.pizzolatto Link to comment
jeffrey.morris Posted December 10, 2020 Author Share Posted December 10, 2020 I changed dvec3 to vec3 and it worked but car's red box sits on the ground. I changed Node ground = World.GetNodeByName("ground"); to Node ground = World.GetNodeByName("ground_plane"); The car's wheel sits on the ground but I can't get it to move. I can turn the front wheels left and right. Link to comment
mark.pizzolatto Posted December 10, 2020 Share Posted December 10, 2020 Have you tried printing the variables at key locations (like velocity when the key gets pressed and when it updates in UpdatePhysics)? If its not changing then the problem might lie in there, if it IS then maybe the value is off (i.e., to small)? Link to comment
jeffrey.morris Posted December 11, 2020 Author Share Posted December 11, 2020 How can I print the variables at key locations? Link to comment
mark.pizzolatto Posted December 11, 2020 Share Posted December 11, 2020 This tutorial should help with printing and where to find the readouts: https://developer.unigine.com/en/docs/2.13/videotutorials/how_to/how_to_cs/logging?rlang=cpp AND the documentation (make sure to click the C# option in the top right corner: https://developer.unigine.com/en/docs/2.13/api/library/common/class.log?rlang=cs As for what are "key" locations - it usually where variables are getting set, modified, updated, etc... So using the car.UpdatePhysics() as an example I (personally would do - however you could do it however it fits your needs and style): bool UpdatePhysics() { // set angular velocity for rear joints //print to see if velocity is what we expect it - print out velocity when you set it. //If the value that one prints and this one prints are the same then its not an issue with the variable getting set //test every value Log.Message("UpdatePhysics - Velocity: {0}\n", velocity); //two seperate log messages or uncomment the next line for both in one statement //Log.Message("UpdatePhysics - Velocity: {0} -- Torque: {1}\n", velocity, torque); wheel_joints[2].AngularVelocity = velocity; wheel_joints[3].AngularVelocity = velocity; // set torque for rear joints Log.Message("UpdatePhysics - Torque: {0}\n", torque); wheel_joints[2].AngularTorque = torque; wheel_joints[3].AngularTorque = torque; return true; } Link to comment
Recommended Posts