When i am adding Rigidbody to Particle System it flying to Y axis? - particle-system

I am working on Particle System but one thing i noticed that when in add component i am adding Rigidbody to Particle System it fly to Y axis.
I am not unable to find proper reason for this please let me know if i am doing something wrong.

Related

Unity3D - Replay a non-looping Particle System

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();

How to animate textures in a 3d model?

I wish to have a animated 3d texture in my LibGDX code but I am struggling to find out how to do it.
I assume how this "should" be done is either;
a) Directly accessing and modifying the texture on the model. (via a pixmap? ByteBuffer?)
or
b) Prerendering a big image containing all the frames (say, 20) and then moving the UV co-ordinates to create the illusion of the animation. (akin to ImageStrips in 2d/webdesign).
I did work out how I could completely replace the material eachtime, but that seems a much worse way of doing it. So if anyone could show the commands I need to do either a) or b) (or a similar optimal method) I would be great-fall.
Maths I am fine with. The intricacies of OpenGLES or GDX I am not :)
(The solution should at least work HTML/Android compiles, ideally everything)
Since the latest release it is very easy to play a 2d animation on a 3d surface. First make sure to get familiar with the 2d animation concept, as explained over here: https://github.com/libgdx/libgdx/wiki/2D-Animation. Then, instead of using a spritebatch, you can use the TextureRegion (which Animation#getKeyFrame returns) to set the material of the surface, as shown here: https://github.com/libgdx/libgdx/blob/master/tests/gdx-tests/src/com/badlogic/gdx/tests/g3d/TextureRegion3DTest.java. So basically you would get in your render method:
attribute.set(animation.getKeyFrame(stateTime, true));
Or if you want a more generic approach:
instance.getMaterial("<name of material>").get(TextureAttribute.class, TextureAttribute.Diffuse).set(animation.getKeyFrame(stateTime, true));
Or, if there's only one material in the ModelInstance:
instance.materials.get(0).get(TextureAttribute.class, TextureAttribute.Diffuse).set(animation.getKeyFrame(stateTime, true));
If you have the memory for it I would definetly choose b), it is easier on the processor. Also, you would only change a uniform's value. However, due to preprocessing it might take some time to open the application.
Get you uniform variable, where you compile your shaders, animationPos should be global.
Gluint animationPos = glGetUniformLocation(shaderProgram, "nameoftheuniform");
Your main loop should pass animationPos value to the shader:
Gluniform1i ( animationPos, curentAnimationIndex);
Add this your fragment shader variables:
uniform int animationPos;
Fragment shader main:
float texCoordY = texCoord.y; //texture coordinates should be passed from vertex shader
float texCoordX = texCoord.x/20.0f; //we are dividing it with 20 since it is the amount of textures that we have and if we use it directly it would try to use all the texture. Whereas the texture stores at 20 different textures.
float textureIndex = 1.0f*animationPos/20.0f; //Pointer to the start of the animation texture.
gl_fragColor = texture2D ( yourTexture, vec2( textureIndex + texCoordX, texCoordY));
Above code assumes that you expanded your textures in the x direction, you can also try to expand it like a matrix, then you need to change the texCoord calculation part. Also that we are using 20 textures.
The option a) is more heavy on the processor and you will be changing the texture every time so it will use pci a bit more, but easier on memory. The question is more like a design decision, but I guess 20 images can be handled so go with option b).
Edit: Added code.

Dygraph: mouse pointer goes out of sync

When I try to rotate the dygraph by 90 degree, the mouse pointer gets out of sync and doesn't follow the highlighted point in the graph. I understand this is because now x - axis becomes vertical and y axis as horizontal but I don't know how to fix this issue. I tried pointing my own logic inside mousemove_ function of dygraph.js but couldn't make it work. Can someone please suggest me the code change I need to make.
Note: My app has both dynamic and static graph, so the mouse pointer should in sync with highlighted point for both static and dynamic graph
This came up in the dygraphs-users mailing list. See this thread: Best way to draw the graph vertically, particularly Ransom Christofferson's message.

how to actor render to Particular posistion without any inputprocess

i'm new to libgdx, I'm trying to make a sprite move to particular target. I can make the sprite move perfectly in x position. i`d move to target position without inputprocess like a enemy. I've tried a few different things but at this point its just guessing and checking.
o(actor) render to target from any position of screen.
/*
o((qx,qy)actor)
|
|
v
((lx,ly)actor)o--->target(tx,ty)<------o((rx,ry)actor)
*/
pls helpme ...
I suggest you take a look at Universal Tween Engine. It's perhabs some overkill to just linealy progress a value across time but it will handle all the things you need. Just read the GetStarted page on the GoogleCode project of it to learn the basics.
Also, you can run a demoApp that showcase it's potential.
Here it's in HTML5
Here it's in Desktop
And here it's in Android
All three are done in LibGDX by the way.

libgdx: Is there a way to "fast-forward" particle effects?

I've worked with Game Maker previously to using libgdx, and one thing you could do is skip ahead in a particle's animation. For instance, if you have a snow particle effect, when you enter a room the snow particles would only just begin falling. But if you used the part_system_update() method repeatedly upon entering the room, you could "fast-forward" the effect, making it appear as if the snow had been falling before you entered the room. Is there a way to achieve that same result in libgdx?
Yes, you can update it when is created using the desired big float.
ParticleEffect#update
float startp = 0.5F; //for example
particleEffect.update(startp);