ahmad.karami Posted April 20, 2020 Share Posted April 20, 2020 Hi Unigine Team, I make a box , then I want the box follow me , but does not work , I think here is a terrible bug in Unigine 2.11.0.1 , Also I tested the Box Physics=rigid(Dynamic Mesh) & without Physics then UpdatePhysics/Update methods , but does not work , also I tested UpdateSyncThread & UpdateAsyncThread , result is same with terrible bug! public vec3 p; Code 01 (Once Run in Update Method!) void Update() { // write here code to be called before updating each render frame p=node.FindNode("first_person_controller").Position; World.GetNodeByName("box1").Position=p; } Code 02 (The rotation continues and runs frame by frame!) void Update() { // write here code to be called before updating each render frame World.GetNodeByName("box1").Rotate(Game.IFps*100,0,0); } NOW , Why for code 01 is once run?! but for code 02 is running without problem (rotating) ? + There is also a problem with the spoiler! Link to comment
silent Posted April 20, 2020 Share Posted April 20, 2020 Hi Ahmad, May I ask you to use <code> tag to format source code? Here it is: About your current issue, it's hard to tell what is going on. Have you tried to check if your p=node.FindNode("first_person_controller").Position is valid? Maybe here there is a null pointer exception? Why not use the same GetNodeByName() for that? 1 How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
ahmad.karami Posted April 20, 2020 Author Share Posted April 20, 2020 (edited) 3 hours ago, silent said: Hi Ahmad, May I ask you to use <code> tag to format source code? Here it is: About your current issue, it's hard to tell what is going on. Have you tried to check if your p=node.FindNode("first_person_controller").Position is valid? Maybe here there is a null pointer exception? Why not use the same GetNodeByName() for that? also this three line code, compiled success , also make a same error in runtime...in update method... p=node.FindNode("first_person_controller").Position; World.GetNodeByName("box1").Position=p; Unigine.Console.Run(p.ToString()); Yes I used GetNodeByName Mr @silent but only ONCE RUN... I tested codes bellow , compiled success , but once run in update method... code01 p=World.GetNodeByName("first_person_controller").Position; World.GetNodeByName("box1").Position=p; Unigine.Console.Run(p.ToString()); code02 World.GetNodeByName("box1").Position= World.GetNodeByName("first_person_controller").Position; Unigine.Console.Run(p.ToString()); code03 World.GetNodeByName("box1").Position= new vec3(World.GetNodeByName("first_person_controller").Position); Unigine.Console.Run(p.ToString()); of course code 02 and code 03 is p= (0,0,0) Edited April 20, 2020 by ahmad.karami Link to comment
silent Posted April 20, 2020 Share Posted April 20, 2020 From the attached screens I can see that code executes multiple times (not a single one as you mentioned). Also, instead of Unigine.Console.Run(p.ToString()); use Unigine.Log.Message($"{p.Tostring()}\n"); If you still want to create some kind of the player persecutor behavior you can use attached component. Just drop it to the box and specify the player to follow. Thanks! Persecutor.cs How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
ahmad.karami Posted April 20, 2020 Author Share Posted April 20, 2020 13 minutes ago, silent said: From the attached screens I can see that code executes multiple times (not a single one as you mentioned). Also, instead of Unigine.Console.Run(p.ToString()); use Unigine.Log.Message($"{p.Tostring()}\n"); If you still want to create some kind of the player persecutor behavior you can use attached component. Just drop it to the box and specify the player to follow. Thanks! Persecutor.cs 613 B · 1 download Thank you Mr @silent I have very bad news , I implemented/tested your csharp code file , Only Once Run , then box do not follow me !!! may be this code file relegated to other version Enterprise & Sim ... but for free version does not work , also this Unigine.Log.Message($"{p.Tostring()}\n"); line , I tested but show error in compile !! I attached my c# file , please see , also disable Unigine.Log.Message for compiled success :-( BoxFollowMe.cs Link to comment
ahmad.karami Posted April 20, 2020 Author Share Posted April 20, 2020 (edited) Plus , I have +5 years experience C++ & C# (Medium) and Other languages like Text/Graph , this is my account in youtube https://www.youtube.com/channel/UCN9MWr1LFeR7i5AdkyxVMbg/playlists I wrote C++/tools book for CryEngine 5.x (634 golden pages) http://www.mediafire.com/file/6to3x5aj2ajykdw/CryEngine_5_Book-Persian_Language-Ahmad_Karami.pdf/file Trust me and I have enough experience, I don't mean advertising for myself. I think there are a lot of bugs that need to be fixed ... at least C# API for unigine ... Thanks a lot Edited April 20, 2020 by ahmad.karami Link to comment
silent Posted April 20, 2020 Share Posted April 20, 2020 Hi Ahmad, I've played a little with your component and I think I found what is going on. The first_person_controller.node being placed as NodeReference returns null when I try to get it. I've solved it by placing this node as Node contents: After that I've replaced Target to follow in BoxFollowMe.cs to a new node: And it looks like everything is fine right now and box is following player as it should. We will try to find out why NodeReference object didn't work at the first place. Thank you for finding this! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
mark.pizzolatto Posted April 20, 2020 Share Posted April 20, 2020 1 hour ago, ahmad.karami said: Unigine.Log.Message($"{p.Tostring()}\n"); line , I tested but show error in compile !! Well - I think that was a minor typo (it happens ;) ) BUT: p.ToString() was working, was it not? When you changed to p.Tostring() it stopped? So try capitalizing the 'S' in String -> Tostring() => ToString() Link to comment
ahmad.karami Posted April 20, 2020 Author Share Posted April 20, 2020 (edited) 3 hours ago, silent said: Hi Ahmad, I've played a little with your component and I think I found what is going on. The first_person_controller.node being placed as NodeReference returns null when I try to get it. I've solved it by placing this node as Node contents: After that I've replaced Target to follow in BoxFollowMe.cs to a new node: And it looks like everything is fine right now and box is following player as it should. We will try to find out why NodeReference object didn't work at the first place. Thank you for finding this! Hi Mr @silent , You're welcome ;-) , I tested top code with content node not reference node, box follow me now , Thank you :-) Edited April 20, 2020 by ahmad.karami Link to comment
ahmad.karami Posted April 20, 2020 Author Share Posted April 20, 2020 (edited) 3 hours ago, mark.pizzolatto said: Well - I think that was a minor typo (it happens ;) ) BUT: p.ToString() was working, was it not? When you changed to p.Tostring() it stopped? So try capitalizing the 'S' in String -> Tostring() => ToString() Hi @mark.pizzolatto , I know , thank you for your suggestion , I already tested , does work ;-) Edited April 20, 2020 by ahmad.karami Link to comment
ahmad.karami Posted April 20, 2020 Author Share Posted April 20, 2020 6 hours ago, ahmad.karami said: also this three line code, compiled success , also make a same error in runtime...in update method... p=node.FindNode("first_person_controller").Position; World.GetNodeByName("box1").Position=p; Unigine.Console.Run(p.ToString()); Yes I used GetNodeByName Mr @silent but only ONCE RUN... I tested codes bellow , compiled success , but once run in update method... code01 p=World.GetNodeByName("first_person_controller").Position; World.GetNodeByName("box1").Position=p; Unigine.Console.Run(p.ToString()); code02 World.GetNodeByName("box1").Position= World.GetNodeByName("first_person_controller").Position; Unigine.Console.Run(p.ToString()); code03 World.GetNodeByName("box1").Position= new vec3(World.GetNodeByName("first_person_controller").Position); Unigine.Console.Run(p.ToString()); of course code 02 and code 03 is p= (0,0,0) I tested a file top , does work ;-) if you want , you can see my code, I attached here , box follow me (player) , with content node not reference node , GREAT... I continue for Discover the world of C# API Unigine ;-) TestCSharpCode.cs Link to comment
ahmad.karami Posted April 20, 2020 Author Share Posted April 20, 2020 (edited) Thank you Mr @silent You SOLVED ... the c# file code attached ;-) with content node not reference node :-) plus , Box follow me(player) & box look at player :-) and show message ... BoxFollowMe.cs Edited April 20, 2020 by ahmad.karami Link to comment
Recommended Posts