Adam's Lair Forum

game development and casual madness
It is currently 2017/04/25, 10:45

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject: Re: 2D Collider
PostPosted: 2016/10/12, 19:50 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 1948
Location: Germany
Role: Professional
Ran the launcher as-is, crashes with this logfile. Looking into it, it becomes apparent that the Duality core is indeed loaded twice, because it's in the Plugins folder as well as the root folder. This already causes issues, see here:

Code:
[Core] Wrn:   Actual Type 'Vector3' of object value in field '<Movement>k__BackingField' does not match reflected FieldType 'Vector3'. Trying to convert...'
[Core] Wrn:     ...failed! Discarding value '(0, 0, 0)'
[Core] Wrn:   Actual Type 'Vector3' of object value in field '<oldPosition>k__BackingField' does not match reflected FieldType 'Vector3'. Trying to convert...'
[Core] Wrn:     ...failed! Discarding value '(0, 0, 0)'
[Core] Wrn:   Actual Type 'Vector3' of object value in field '<Position>k__BackingField' does not match reflected FieldType 'Vector3'. Trying to convert...'
[Core] Wrn:     ...failed! Discarding value '(64, 64, 0)'


Later on, there is also a MethodNotFoundException like you experienced, but since a core-loaded-twice situation is highly unstable in any case, I first tried to fix this - by removing everything from the Plugins folder that isn't a plugin or direct dependency library of a plugin. Only Duality.AABB.dll remained there (Edit: And FarseerDuality, because I forgot to remove it, but it didn't seem to cause problems in this specific case).

Started the launcher again and it works! Nothing bad in the logfile either.

So.. given that the core shouldn't be in Plugins anyway and your custom code seems to work just fine if it isn't, I'm not sure what the problem is. Did I miss something? :eh:

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
 Post subject: Re: 2D Collider
PostPosted: 2016/10/12, 22:50 
Forum Adept
Forum Adept
User avatar

Joined: 2015/03/15, 02:49
Posts: 351
Location: Out there
Role: Hobbyist
I am sorry for being slow in my answers. I guess there must have been some leftovers with my previous tryouts.

I have dug deeper into this, and the solution might have come along they way, by cleaning the project/solution (something I read here).

Indeed, I have forgotten to remove Duality.dll and DualityPrimitives.dll.

Tomorrow, when I get my hands dirty again, I'll try to make everything from scratch, making sure I don't take a misstep somewhere.

Thanks for taking the time. I believe this has been a bit of a human error, further expanded by making a mess while trying for solutions.

_________________
Hello there! Nice to meet you!
I have github. Apologies in advance for bad coding practices.


Top
 Profile  
 
 Post subject: Re: 2D Collider
PostPosted: 2016/10/14, 15:40 
Forum Adept
Forum Adept
User avatar

Joined: 2015/03/15, 02:49
Posts: 351
Location: Out there
Role: Hobbyist
This is seriously nerve wracking...

Start a new project: Class Library (Portable) TRhe targets are whatever is selected. Go!

I have a Duality instalation where I reference Duality, DualityPrimitives and Plugins\Tilemaps.core.dll.

In my class lib, I just write this:
Code:
public string CountTiles(Tilemap tilemap)
{
     return $"{tilemap.Tiles.Count()}";
}



I slap the built .dll in the plugins folder.

Fire up Dualitor.

In my scene, I add a tilemap with default settings.

Open VS to add code. Rename "YourCustomComponentType" to "Start"

Implement interface Initializable.

Reference my ClassLibrary, tilemaps.core.dll that are in the plugins folder.

On the Init method, I invoke my CountTiles() method, passing the tilemap as an overload.

Code:
Class1 c = new Class1();
c.CountTiles(Scene.Current.FindComponent<Tilemap>();


Press F6, Dualitor refreshes.

In the scene, I add my Start component to the camera, that immediately spits the MissingMethodException.

This just happened in the smallest example I can think of. This HAS to be something with the way I reference the libraries. Upon build, all the DLLs are in the same output folder. Weren't Tilemaps.core.dll and my class be inside a Plugins folder?

_________________
Hello there! Nice to meet you!
I have github. Apologies in advance for bad coding practices.


Top
 Profile  
 
 Post subject: Re: 2D Collider
PostPosted: 2016/10/14, 16:15 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 1948
Location: Germany
Role: Professional
Looks like you found a minimal sample to reproduce. Any chance you can upload this?

eyeliner wrote:
Upon build, all the DLLs are in the same output folder. Weren't Tilemaps.core.dll and my class be inside a Plugins folder?

Which folder do you mean exactly? bin/DebugOrRelease/ it where your compiled stuff goes, but there is a post-build event that copies it over back to Plugins.

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
 Post subject: Re: 2D Collider
PostPosted: 2016/10/14, 16:30 
Forum Adept
Forum Adept
User avatar

Joined: 2015/03/15, 02:49
Posts: 351
Location: Out there
Role: Hobbyist
bin\Release.

And all the DLLs are there. No Plugins subfolder

_________________
Hello there! Nice to meet you!
I have github. Apologies in advance for bad coding practices.


Top
 Profile  
 
 Post subject: Re: 2D Collider
PostPosted: 2016/10/14, 17:00 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 1948
Location: Germany
Role: Professional
No Plugins subfolder is totally fine, as long as your Duality main folder has one. That's where the post-build step should copy your files. So yes, your Assemblies should be there. ^^

Edit: I'll try to reproduce this with your steps, but it might take a few days, won't have much time this weekend.

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
 Post subject: Re: 2D Collider
PostPosted: 2016/10/16, 12:45 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 1948
Location: Germany
Role: Professional
Found the problem. There was an unexpected race condition in resolving dependencies that triggered only when a non-plugin library had a plugin dependency. I'm triggering a new minor release cycle, check for package updates in about 30 minutes for a fix. Please let me know if it works after that!

Sorry for the inconvenience and thanks for reporting this bug :+1: :)

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
 Post subject: Re: 2D Collider
PostPosted: 2016/10/17, 00:02 
Forum Adept
Forum Adept
User avatar

Joined: 2015/03/15, 02:49
Posts: 351
Location: Out there
Role: Hobbyist
It works in the small test I made. Safe to assume all is well. No errors of any kind.

Well, while figuring out what was wrong in my end, I managed to learn a few more things, at least.

And no problem about the inconvenience. I am still a way from where I want to be in my lib.

I want to document it well, and make sure somethings are actually *automagic*, because for now the lib only takes into account the position if the origin of the tile renderer is in the top left.

Not sure if I should implement movement logic as well. But I shall get there soon and ask away.

_________________
Hello there! Nice to meet you!
I have github. Apologies in advance for bad coding practices.


Top
 Profile  
 
 Post subject: Re: 2D Collider
PostPosted: 2016/10/25, 13:00 
Forum Adept
Forum Adept
User avatar

Joined: 2015/03/15, 02:49
Posts: 351
Location: Out there
Role: Hobbyist
More news:
The AABB is generated using the tile editor's collision shape, so just create a tilemap, set the collision shape to solid and done. The rest is automagic.

There's a movement logic that can be used, comprised by gravity, friction that can (or not) be set. It's completely optional, so one can just use their own implementation.

Todo:
Moving platforms.
Tiles that can be traversed only in a given direction.
Wall jump/Grab(?)

_________________
Hello there! Nice to meet you!
I have github. Apologies in advance for bad coding practices.


Top
 Profile  
 
 Post subject: Re: 2D Collider
PostPosted: 2016/10/25, 23:34 
Forum Adept
Forum Adept
User avatar

Joined: 2015/03/15, 02:49
Posts: 351
Location: Out there
Role: Hobbyist
Created a shortish video about setting up the plugin.

Notable, is the step of making the origin points the top left. Will work on it.


_________________
Hello there! Nice to meet you!
I have github. Apologies in advance for bad coding practices.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group