I start to try clone this game with box2d/cocos2d-x
https://play.google.com/store/apps/details?id=com.miniclip.carrom&hl=en&gl=US
and I have multi problem and need your help.
first: how I can simulate surface friction?
I try to use SetLinearDamping & SetAngularDamping but the result is not very interesting.
i use b2FrictionJoint and solve it.box2d use b2FrictionJoint for top-down friction. The joint provides 2D translational friction and angular friction
Related
I'm following the Survive Shooter Unity3D tutorial and have come across several inconsistencies between the Unite Day presentation and actual behavior in Unity 5.3, such as animation transition and other small issues I had to figure out to achieve the desired gameplay result and follow the tutorial.
One issue I'm unable to resolve is replaying a non-looping particle system. In the game hit particles are emitted whenever an enemy is shot, but when running the game these particles are emitted once and not upon following hits.
This is the particle system configuration:
The original code simply re-positions and re-plays the emission:
// Set the position of the particle system to where the hit was sustained.
hitParticles.transform.position = hitPoint;
// And play the particles.
hitParticles.Play();
I've tried resetting and clearing the system but that didn't work:
hitParticles.Clear();
hitParticles.time = 0;
hitParticles.Play();
How do I replay the particle emission?
thanks!
To reply the ParticleSystem try to use ParticleSystem.Emit(...) with parameters that suits your animation like:
hitParticles.Emit(5);
If you're using Unity 5.3.1, then it sounds very much like a bug(http://issuetracker.unity3d.com/issues/particle-system-plays-only-once).
If you need to reset immediately Particle system and repeat it (For example Rifle barel explosion) I would recommend you this:
ShootParticles.Simulate( 0.0f, true, true );
ShootParticles.Play();
I try to create simple particle system containing 2 emitters(controllers) : 1 for fire and 1 for smoke. i'm doing it problematically and not using editor. I started with fire and create BilboardParticleBatch set texture and the result was not good at all. The reason is that inside batch the blending function is not correct. So I override it in my own batch and change it to GL_SRC_ALPHA, GL_ONE - this produce better results.
So now using my batch the fire is looking good. Then I want to add smoke, so here I want to use Not pre-multiplied blending, so again I created new batch extending BillboardparticleBath and make it to use SRC_ALPHA, ONE_MINUS_SRC_ALPHA and assign it smoke texture. So the smoke is perfect.
The main problem is how to merge both controllers. If I put them both to ParticleEffect and put this Effect in ParticleSystem then I'm able to render them together but the problem is that when particle from both emitters overlaps, sometimes they have wrong blending. It is because probably they are not sorted together as they use 2 batches. The sort is applied not by effect level but by batch level. So this is not a sollution :(
I can try using only one batch and use TextureRegion influencer in order to use different textures for smoke and fire inside 1 batch, but how to solve problem with different blending as it will be one and the same for the batch.
Is it a way somehow to merge both batches in one and tell it to render fire using additive and smoke using just alpha.
Thanks in advance!
Problem is solved. Now it is working fine with 2 batches. I just add depth testing function to the material when override the particle batch.
How to know the coordinates of the path if you know the azimuthal angle. I wanna move my camera around an object in away 3d.
Move camera in Spherical coordinate system by Interpolating from starting azimuthal angle to target - it will be your trajectory.
You can convert from\to Cartesian coordinate system to retrive\pass current coordinate to away3d renderer.
You all so may want to use non-linear camera acceleration(for more realistic feel) it can be implemented with Bézier curves
PS. I will be thankful if your publish you realisation because i will need this functional in my next project. You will save me a lot of time :)
Or just use translation and rotation methods that camera inherits from Object3D it's all covered in Away3D example projects. Allso Away3D has path helper package
I'm using the caurina.transitions.Tweener; class with AS3 to tween a 3D object through my 3D environment (created with alternativa3D platform) from point A to point B. And everything works great, they move as intended from where they were to where I told them to go.
I was wondering if there was a way to make the object stop moving (or tweening) if the slope they were trying to walk over was too steep (like a giant hill or mountain in real life)?
This is basically the code I am using for this:
var playerDistance: Number = Vector3D.distance(
new Vector3D( _escapeeManager.activeEscapee.x,
_escapeeManager.activeEscapee.y,
_escapeeManager.activeEscapee.z ),
intersectData.point );
Tweener.addTween( _escapeeManager.activeEscapee, { x:intersectData.point.x, y:intersectData.point.y, time:(playerDistance/_escapeeManager.activeEscapee.speed), transition:"linear" } );
And if you'd like to see an example in the game I'm developing, it can be found here:
http://redmenmusic.ca/godsend.html
Thanks for your help guys!
It seems a bit odd to use Tweener for anything other than superficial animations - you probably need to implement a more complex system to handle object movement, collision detection, slopes etc.
The caurina.transitions.Tweener has some properties that could come by handy for your problem. I'am not saying it's the Tweener is the best way, bit it will get you where you want I guess :).
The official Tweener documentation website can be found here: http://hosted.zeh.com.br/tweener/docs/en-us/. The section 'Tweening parameters' would be a interesting read for you.
So for your problem, I would suggest to approach it this way:
There is a onUpdate event which is executed on every update of the Tweener. On every update you could check if the slope is to steep or not.
Example:
Tweener.addTween(myMovieClip, { x:100, time:1, onUpdate:function() { /* check here if the slode is to steep - if it is you can remove the Tweener on the object and proceed with an other function */ }});
I hope it's clear :)
Good luck!
I'm currently working on a game with html5/js, using box2dweb for the collision but I'm running into the issue where I am required to scroll the level with the player. Box2d renders directly to the 2d context so I think in it's current state there is no way to shift the render portion of the canvas?
In as3 you could just put everything in a movieclip and change it's position accordingly.
So, is it possible in anyway to have control of a camera of some sorts or the render portion of the canvas object to shift it's 'position' to keep the player centered at all times?
Thanks in advance,
M0rph3v5
Box2D, by itself, doesn't draw anything, it just calculates positions/collisions.
It offers the so-called "Debug Drawing", but it's purpose is... debug.
Anyway you could start from there to add all the needed features.
http://code.google.com/p/box2d/wiki/FAQ
Yeah I figured, turns out I had to use a context.translate right before the debugdraw as well to 'shift' everything. Got it working nicely now.
EDIT:
The code I'm currently using
context.save();
context.translate(-1*xpos+(canvas.width/2),-1*ypos+(canvas.height/2));
context.rotate(cars[carid].angle);
context.drawImage(carSprite, -carspritewidth/2, -carspriteheight/2);
context.restore();
where xpos and ypos are the x and y positions of the car, after that i just draw the actual car sprite at 0,0 (with the carsize divided as the center).