Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by ajainvivek

Hi ,

I hav been usin ver 1.19 its really awesome with introduction of sloped collision tiles.
I hav small issue,my entity size is 68,63 when it runs over the sloped collision tiles .I need the entity to tilt with sloped collision tile, currently the entity is raising horizontally when it runs over it.....Hope u got the issue wht i m facin...is thr any solution available....


Thanks

1 decade ago by Arantor

It's kind of hard to understand what you're saying...

1 decade ago by littlefoot

I think he's saying that the entity goes up and down slopes at the same angle as it goes across horizontal collision tiles and wants to be able to have the angle of the player entity change according to the angle at which they're walking up and down these slopes. I'm actually curious about this as well.

1 decade ago by ajainvivek

littlefoot has got my point wht i was tryin 2 convey.... let me explain the scenario i m facin... i hav biker entity ...when the biker rides over the sloped collision tile.... he doesnt change the angle according to the sloped tile.... meanwhile i was doin R&D on the internet i figured out in CanvasRider game they pretty well worked on the logic... but hw do i put up the same logic in ImpactJS 1.19..

Thanks in Advance

1 decade ago by Arantor

It would be easier to follow what you're asking if you spent more time explaining it in recognisable English, rather than using shorthand or slang...

Anyway, the slope behaviour is less designed for angle behaviour but for general collision detection.

That said, you could use the handleMovementTrace method of your entity, with pass in object res, which will provide details in res.collision.slope, and then you'll have to draw it manually rotated, check out the physics demo, which shows drawing bullets at arbitrary angles.

1 decade ago by gxxaxx

I have found that I can set the "flip" and "angle" of the currentAnim to good effect.
NOTE: I store the angle in my entities as degrees. So when I stuff that value into the currentAnim I have to do a conversion to radians -- dom gave us a handy prototype to convert with 1.19 :)

You would convert the angle up when on a slope, then covert the angle back to 0 when
not on a slope.

The animation.js will handle drawing the entity with an angle just fine. I use this to angle torches in my dungeon.

As @Arantor says you can get easy access to the slope angle in the handleMovementTrace.

	flip: {x: false, y: false},
	angle: 0, // stored as degrees in entity -- remember currentAnim wants Radians
	....

	var anim = this.currentAnim;
	anim.flip = this.flip;
	anim.angle = this.angle.toRad();

1 decade ago by ajainvivek

@Arantor........

Let me explain the scenario in detail once more..... i have biker entity and ramp entity in the game...when biker rides over the ramp , the biker doesnt change the angle according to the ramp...

after riding over the ramp ... the biker shld fall from the ramp back to the ground position...

can u pls hav a look @ the link http://canvasrider.com/tracks/featured.... a similar sort of game i m developing with ramp and bike....

1 decade ago by Arantor

I could understand you before, just trying to make the point that if someone generally can't be bothered to explain things in proper English, people can't usually be bothered to help - it make it so much easier when everything is explained in a way everyone (especially people for whom English is not their first language) can understand.

Now, the advice given above is what you need, you will need to use the handleMovementTrace function to get the angle of the tile that the player entity is collided with, and pass that to the player entity itself.

Short of just writing your code for you, I'm not sure what more we can tell you :(

1 decade ago by littlefoot

Quick question on this - in this thread Dominic said that entity collision boxes will not be rotated as Impact supports animation rotation only, and that Box2D needs to be used to rotate the actual entity.

Being new at this I managed to hack together something that is sort of how I want it - but while visually the player seems to be rotating when going up and down slopes it also seems to be floating away from the tile surface and I'm thinking that this may have something to do with the actual entity not being rotated with the animation. Is this correct and is Box2D the only real way to have the entity rotate 'properly' up and down slopes?

Here's my code (like I said, this is totally hacked together, I'm still getting my brain around this. I tried using the advice in this thread as best I could):

In entity.js

handleMovementTrace: function( res ) {
    
    ig.global.animationangle = res.collision.slope.y;

    // Continue resolving the collision as normal
    this.parent(res); 
},

In update function of entity.js:

 this.currentAnim.angle = ig.global.animationangle;

1 decade ago by Arantor

Yeah, that makes sense, the tile support is designed for platform type support, which doesn't need rotational support for collisions, only as far as gravity and holding the player up is concerned.

If you rotate the player you need to rotate collision, and since rotation of the image is more handled by the canvas than Impact, it makes sense that it wouldn't support rotational collisions unless it absolutely had to, due to the performance implications.

Thus to rotate collision, Box2D is the answer and I would again point to the physics demo which, as far as I know, uses this on the bullets to handle colisions.

1 decade ago by Jerczu

In the handleMovementTrace - res object has an info on the slope you are currently on and you get the info about the angle of the slope as well you can calculate your entity rotation based on the tile slope angle.
Page 1 of 1
« first « previous next › last »