I've recently upgraded my project to 5.6.1f1.
I have a homing missile that tracks a target, and has a particle system attached to it to simulate the smoke.
Before I upgraded the project, the smoke worked well. I had a continuous supply of particles behind the missile that had a nice smoke effect. I forget which version of Unity I used before the upgrade (I think 5.4), but the emission module of the particle system only had a rate setting.
Now that I have upgraded to 5.6.1f1, my particles from my smoke are separated, like the steam coming out of a steam train:
The emission module now has rate over time and rate over distance. I've played around with these settings but nothing seems to adjust to how I want.
I've narrowed down to the fact that my missile is travelling at a very high speed. If the missile travels slower, then the particles look better. But, a missile is a missile and travels fast like my other objects. In the previous version of Unity I was using (I think 5.4), the speed of the missile did not affect the emission of the particles.
So, I guess my question is: How can I have a continuous emission of particles that isn't affected by speed?
(For reference, here is how I want my particles to look, regardless of the speed the missile is travelling)
For anyone looking for an answer to the same problem, I found this post.
"From Unity 5.5 onward, particle system (PS) that uses emission rate over distance or inherit velocity (both heavily used in our particle effect assets) and is parented to a rigidbody (RB) object will appear not functional when you drag the object (with RB component) or change the position values in transform component.
The reason is that RB velocity has overriden any form of position translation to feed the velocity values to PS modules which require velocity data to work properly. Simply put, you should use Rigidbody.velocity (not even Rigidbody.position which is for detecting boundary) instead of Transform.position/Translate to move the object."
I simply changed:
transform.position += transform.forward * speed * Time.deltaTime;
to
rb.velocity = transform.forward * speed * 40 * Time.deltaTime;
Which gave a similar speed and the smoke was not separated.
I had this problem once. The particles are inheriting the parents velocity. I can't remember where it is located, but there is a property called "Emitter Velocity Scale" that should be set to 0.
This should be located somewhere on the particle system itself.
There is also an answer about something changing in the particle system on that specific update.. Quoted from this unity forum post:
Under the particle system click the renderer tab to open it, check the material slot if it says none click the circle on the material tab and choose the Default Particle Material and then it will work right.
Related
player and object both have colliders and rigidbodies, object has position and rotation locked, player has only rotation locked. When the player goes to the blocks, the player goes through the blocks, although they do give a bit of resistance. To move the player im setting the rigidbody's velocity, and doing that in FixedUpdate.
i have no idea why this is happening, any ideas?
main part of the code is:
rigidBody.velocity = new Vector3(direction.x, rigidBody.velocity.y + (-Gravity * Time.deltaTime), direction.z);
(direction is determined by the WASD keys, and i'm using my own gravity)
First of all, you do not need to multiply the velocity by time.DeltaTime, because you are moving your object in the FixedUpdate() method; Which uses fixed time intervals since the physics engine does not run in sync with the regular game engine. Also, both objects do not need rigidbodies in order to collide with one another. I suggest looking at your collision matrix in settings and verifying that everything you need collision for is checked correctly. As others have said as well, check your kinematics on the rigidbody.
A last suggestion for working with your own gravity. Do not change the actual gravity value of the game engine. It is typically recommended that you use a multiplier variable and apply it to the constant gravity already set by the physics engine. If you are completely editing the gravity, than maybe consider using a character controller instead.
I guess it has something to do with what the documentation says "In most cases you should not modify the velocity directly, as this can result in unrealistic behaviour".
Try to use AddForce() or similar functions to alter the properties of the rigid body. Colliders etc will then work as expected.
I am trying to extinguish the fire particle using Unity water particle. Which is working. But the water particles Splash effect is overflowing. I tried to scale it but it"s not working. So how can I reduce the splash effect?
To stop the water particles from overflowing you can do a combination of two things:
decrease emission rate of particles or the velocity of particles. You find these things under certain modules. Here is the list of modules:
To change the emmission rate, find the particle system in the inspector and go to the emmission module. If not already opened - open it. Adjust the Rate over Time variable to a lower value, you should notice a lot less particles being formed.
Then to change the velocity of the particle system, this one can be change a few ways. And, it depends on how you change it for your water to go upwards. A good place to check is in the Velocity over Lifetime module and you want to decrease the speed modifier or the linear velocity values.
You may also want to check if lowering any velocity values from Limit Velocity over Lifetime, Inherit Velocity, Force over Lifetime solves your issue.
EDIT
To stop emitting particles just set the prediscussed particle emission Rate over Time back to 0. To do this inscript:
GetComponent<ParticleSystem>().emission.rate = 0.0f; // Or a higher number if you want to restart it
Also, when I notice your particle system, you don't have to add burst like I have done so in the examples. Just change the specific variables mentioned.
I'm creating a fast-paced, 2D side-scrolling game on Unity 5.2, building my terrain out of discrete "blocks", each with its own EdgeCollider2D component.
Having a problem where my character gets bumped upward as it crosses from one block to another (imagine driving your car over a speed bump on the road).
This doesn't happen all the time. Seems to be random, which is even more irritating, as it makes finding a solution more difficult.
I've tried all of the suggestions that I could find for similar questions on this site, including:
Using CircleCollider2D's on the character
making sure the terrain blocks and their corresponding colliders are perfectly aligned. The attached screenshot shows one of the intersections.
changing the "Min penetration for penalty" setting to the minimum allowed value (0.0001)
switching between discrete and continuous collision detection for the character's RigidBody2D
increasing the mass and gravity scale for the character's RigidBody2D
... to no avail.
Beyond building a single, massive terrain object with a single edge collider from start to finish (which I'm trying to avoid), I've run out of ideas. Anything else I'm missing? Is it just a Unity bug?
Help!
Try detect the collision and set the vertical velocity to zero.
void OnCollisionEnter2D(Collision2D col)
{
if (col.gameObject.name.StartsWith("block"))
rigidbody2d.velocity = new Vector2(rigidbody2d.velocity.x, 0);
}
I'm creating Unity2D runner where characters is running on the ground.
I'm trying to force him run with constant speed by applying force with right vector but the movement is jerky.
I'm trying to achieve effect of endless run with permanent speed. It is easy in the air but works different (because of physics) when character is running on the ground.
You could velocity and make sure to turn off gravity. If you are running on the ground make sure you turn this off.
You could implement your own movement where you can update position depending on Time.deltaTime.
Just use the built in character controller that unity comes with. basic directionals and jump. And mouse controls where the character faces.
EDIT:
Use rigidbody velocity and turn off gravity and drag. This will keep your runner running forever.
To implement this yourself. You can update the position of the object in the update method. Something like
Vector3 temp = object.transform.position;
temp.x = speed * Time.deltaTime;
object.transform.position = temp;
Where object is you runner and speed is how fast you would like him to move.
This would be inside the update function.
If you aren't going to be controlling the runner, dont bother with the controller
Use Rigidbody2D.velocity and pay attention to:
The velocity can also gradually decay due to the effect of drag if
this is enabled.
I have been working on a Unity ping pong game using the Leap Motion. I use rigidbody.MovePosition() to move the paddle. However, when I hit the ball (which uses gravity), the paddle launches it too far. Even when I change the masses of both, it doesn't do anything.
What variable should I change to reduce this energy going into the ball?
From the following link.
"MovePosition will put your object at the target location, no matter what. It may push aside other objects in a realistic way, or may blast them out of the way, or may just pass right through them. But it will gladly move you through a solid wall or a mountain.
If you're using MovePosition on a rigidbody to add from where you currently are, it looks like AddForce. With AddForce, the physics step does all the work: applies your velocity, sees the collision and handles the bounce. With MovePosition, the physics step sees you're mysteriously overlapping a solid object. If it isn't too much, it will bounce you apart."
You won't need to use MovePosition. Instead, you can figure out the direction of the shot (based on the position of the ball relative to the paddle). Then you can add an impulse force in that direction to the ball.
Pseudo-code (from the following link):
Vector3 shootDir = ballPosition - paddlePosition; // Calculate direction of the shot
shootDir.Normalize(); // Normalize the shot vector
ball.AddForce(shootDir * speed, ForceMode.Impulse); //Add impulse force in correct direction.
Credit due to Owen Reynolds and Tim Michels.