Page 1 of 1

collision

PostPosted: Sun May 24, 2009 8:42 pm
by j2graves
I'm making a game that is a side scroller, but I have a problem:

I am trying to make the view follow the main actor, the character you play as, and at the same time, I'm trying to create some objects that are supposed to stay on certain points in the screen. for example; I have a health bar that is in the lower left conrner of the screen. the trouble I encounter is making these actors follow the main actor properly:

1. I tried making them child actors of the main actor, but the problem I faced was z-depth. they automatically recieve the same z-depth of the main actor no matter what I do, and I need the health bar to have a maximum z-depth at all times so that you can see it throughout the entire game.
2. I tried to solve this problem by adding an invisible center actor which is always following the main actor, but the problem I encounter is that now the health bar shakes every time the main actor collides with the ground.

someone suggested I get a better collision system. what do I do?

Re: collision

PostPosted: Sun May 24, 2009 9:46 pm
by makslane
Is better make the score, health bar, children of the view.

Re: collision

PostPosted: Sun May 24, 2009 9:49 pm
by j2graves
even when I do it that way, I run into the same problems:

the zdepth inheritance, and the shaking on collision.

Re: collision

PostPosted: Mon May 25, 2009 4:01 am
by BlarghNRawr
actorname.x=view.x;
actorname.y=view.y;

that way the actor only follows the view and not inherit the zdepth

Re: collision

PostPosted: Mon May 25, 2009 2:34 pm
by j2graves
that's where the shaking comes in.

Re: collision

PostPosted: Mon May 25, 2009 4:36 pm
by j2graves
I don't think you people are understanding;
If I use parent, the actors inherit the z-depth
if I use the x= method, the actors shake every time my main actor collides with the ground.

Re: collision

PostPosted: Mon May 25, 2009 5:12 pm
by DST
I got ya j.

The shaking thing is hit and miss; some people experience it, some don't. In my smooth scrolling demo, it scrolls perfectly for some, and shakes for others. Not sure why.

And sometimes it shakes for me too, on other games where i tried using view.x=player.x. Try the smoothscrolling demo, and if it doesn't work, use Feral's child method - move the view to the bottom of the Z plane. If view has a Zdepth of 0, then all its children will have a normal Zdepth!

Re: collision

PostPosted: Mon May 25, 2009 5:50 pm
by j2graves
thanx for your help. the fact is, that no matter what I do, I encounter at least one of these problems. someone told me that I sould get a better collision system. has anyone developed a good collision system that avoids shaking?

Re: collision

PostPosted: Mon May 25, 2009 7:36 pm
by DST
If you're referring to the collision with the ground, and you are using physical response, then yes, the player is constantly colliding with the ground (and shaking).

It's not the view that's shaking. Its the player.

What i do to avoid ground collision shaking is this:

Collision>top side>ground>repeat yes
Code: Select all
yvelocity=0;
PhysicalResponse(MOVE_EVENT_ACTOR_ONLY, USE_CALCULATED_MASS, 1.000000, 1.000000, 0.000000, 1.000000);
 


A physical response with an Final Event Multiplier of 0, with a yvelocity of 0 = _______(fill in the blank)!
This leaves only the xvelocity of the physical response to deal with.

The problem with tiles and clones is that ge includes the corner pixels in its collisions (most engines handle corner pixels differently). this means that walking on top of a new tile also incurs collision with the side of the new tile.

So two methods to this are: 1. use a solid ground actor, not tiles or clones or
2. use a repeating colllision that gives you the effect you want every time. If you use a non repeating collision, there will be a difference between the frames where collision occurs and the frames where they don't (or a difference between when the response actually corrects velocity and when it doesn't need to.) If you want things to be smooth, they need to be constant.

The other things is - remember my perfect collision demo?(yeah, i know, not so perfect).

Well the main point i made there is that a shapechanging sprite will jiggle the physical response around. Try these methods with a solid block that doesn't animate. See if the shapechanging is the problem.

Much of platform physics can be based on yvelocity - for instance, resetting canjump when a player falls - just disable canjump anytime yvelocity is over 2. When he's falling, he can't jump. I use 2 because....lol....the yvelocity incurred in the physical responses can fool it! Usually it doesn't go over one but sometimes it does. 2 is safe, if the gravity is (yvelocity+=1) then each frame picks up 1 velocity, and its only 2 frames to jump disable, so it appears instantaneous.

The question you're asking is simpler than this thread makes it seem. We're saying different things but using the same words (or vice versa) - its difficult for each of us to understand what the other is saying, i guess.

I went thru this before many times, i know exactly what your problem is, but there are many ways around it. There are many ways around any problem.