PDA

View Full Version : Joints in Novashell



-=Uncle Bob=-
01-04-2010, 05:52 PM
Hi, I have a question about joints.

As I see, there is no joint implementation in this version of Novashell. However, they are implemented in box 2d. As I know, Novashell is using box 2d for collision detection and collision response.

I had a problem when I tried to create a 'real-physics-like' chain. I know, that one of the solutions is to use joints. I looked in the source of Novashell and I didn't find anything that would be useful in this situation.

So, is it possible to implement joints? Or solve 'chain-like' problems?

Also, I think about 'attaching' or 'applying some kind of forces, but I think that is 'fake-joint-implementation' and this should not be implemented in the scripts level.

By the way, thank you, Seth. Your framework is great. :)

P.S. And forgive me for my bad English. I'm from Russia.

Seth
01-05-2010, 12:58 AM
Hi,

You are correct about all of this - the best way to do this would be to add access to Box2D's joint support so a script could tell one entity to joint itself to another at a specific offset maybe?

Unfortunately I'm pretty swamped with work with now so it's unlikely that I will get time to play with that anytime soon.

But if you're feeling adventurous I would recommend downloading the Box2D source and playing with its demos if you wanted to try adding it yourself.

For chain like things, the whole idea of 100 entities jointed together sounds too slow anyway, so in a real game situation it may make more sense to make a C++ ChainBrain plugin that manipulates Box2D stuff itself and does everything in a single entity. Unsure.

-=Uncle Bob=-
01-05-2010, 03:57 AM
Thanks for fast reply. :)

Ok, I'll try to implement joints by myself. I'll start from Box2D's demos as you said. And I think you're right about 'ChainBrain' -- it's the fastest way to do what I need.

Also, there is one more problem. I don't know how to classify this problem (bug? or feature?).

I have a 'player spawner' entity. This entity is pretty simple and allows me to create a character by his name (by his script name). It just create player when I start to play in the game (but not in the editor).

Of course, I have a 'Game Pallete' map where some useful entities are placed. There is an 'emitter' entity which is placed in the 'Game Pallete' map too. One of the 'player hero scrips' include 'cool landing state' which copy the 'emitter' entity from 'Game Pallete' map when player fell down from high distance.
(It creates a 'boom like' effect when player landed)

But unfortunately, when it copied the 'emitter' it also initialized all objects on 'Game Pallete' map (at least, it call 'OnMapInsert' method), so 'player spawner' creates second hero when first hero was in 'cool landing' state. I solve this problem by using 'CreateEntity' function, but I think it should be posted here.

Seth
01-08-2010, 06:13 AM
Hmm, I see your problem.

When the Game Palette map is 'touched' when you look up an entity to clone it does initialize everything on it.

I know I had a good reason for this.. uh, but I don't remember it right now. :sweatdrop:

There are a couple ways to work around this, but the simplest is probably to insert this in each Game Palette entity script (in its OnPostInit()) before it actually starts doing things.



function OnPostInit() //run during the entity's first logic update

if (this:GetMap():GetName() == "Game Palette") then
//don't do any more initialization here, we're just a template version
//returning before its assigned a brain or anything
return;
end

//Here is where you actually start spawning players or whatever, this will only get run on cloned versions, NOT the one sitting in Game Palette
end

vulkodlac138
01-14-2010, 09:09 AM
bob, by joints, were you referring to a background feature or a character-type entity? i'm trying to figure out a way to make a player character with multiple sprites for the limbs, a la gundam battle assault or metal slug.

speaking of which, seth, is there a resource i don't know about for making such a brain? or does novashell already support this kind of thing, and i haven't figured it out yet?

amazing program, by the way. this is my first post and i'd be way remiss if i didn't praise it.

Seth
01-16-2010, 12:54 PM
bob, by joints, were you referring to a background feature or a character-type entity? i'm trying to figure out a way to make a player character with multiple sprites for the limbs, a la gundam battle assault or metal slug.

speaking of which, seth, is there a resource i don't know about for making such a brain? or does novashell already support this kind of thing, and i haven't figured it out yet?

amazing program, by the way. this is my first post and i'd be way remiss if i didn't praise it.

Hi,

Internally there is no support for building sprites from multiple pieces, but I *think* it is possible using Entity:Attach(), you can attach say, an arm entity to a body entity, and from there, just use the body entity to move it around.

Where the complication would come in is the animation part... how to get them all to switch at the right time when he starts running instead of walking? That kind of thing.