We've made a flame particle system and we want to attach it to our sword in run animation while the animation is playing.The flame is suppose to be attached on the sword and in run animation sword is moving as expected,but when we the running animation plays the particle system is not attached to the sword, we couldn't find a way to make it attached to sword,it just runs the particle effect but its not sticking to the sword.Is there a way to attach it or do we have to make another game object any advices?
here is a picture of the particle effect and character
and as i sad here it is its not attached to the sword
There are three modes for the ParticleSystem set via the property
Simulation Space
Controls whether particles are animated
in the parent object’s local space (therefore moving with the parent object),
in the world space,
or relative to a custom object (moving with a custom object of your choosing).
Yours seems to be set to World space so no matter where your object moves the particles move related to the world and are not affected by your sword.
So simply set it to the mode you want via the Inspector or set ParticleSystem.MainModule.simulationSpace via code to ParticleSystemSimulationSpace.Local
Simulate particles in local space.
and attach the ParticleSystem to the sword or one of its children
or ParticleSystemSimulationSpace.Custom
Simulate particles relative to a custom transform component, defined by ParticleSystem.MainModule.customSimulationSpace.
So in the case of Custom additionally set the ParticleSystem.MainModule.customSimulationSpace to be your sword. It doesn't need to be attached to it or anywhere nested below it.
Try making the particle system a child of the sword game object.
Related
So I've animated my spaceship. With it's previous rigid form I've got a particle system coming out of it's wings. Now that it's animated, I still want those particles to follow all of it's wings movements, but the particles don't move along with the animations, even being parented with the gameobject's wings, showcase video, 19seconds: https://youtu.be/XJNjT4s4X6I
How can I make those particles move along with it's wings movements? Thanks
I would try to parent them with the bone of the armature, I don't remember if it worked for me though, but what I did is to add an empty in the modeling program to follow the animation and export it, so I can parent it to the things I needed, for you It would be the Particle System.
I used to have a game object used as a sword with sprites with a specific size, despite including quite a bit of transparent space, to ensure these are aligned properly with the player game object:
This ensures the sword follows the player as he jumps by making use of the hero transition like this transform.position = hero.transform.position; , and though there may be issues with sprite changes I would address these later.
However, since I want to have several different equipment, and other sprites of this same sword might need a bigger dimension to look good (such as a sword attack while standing on the ground), I could either make even bigger sprites which would eventually affect performance due to transparent pixels loading, or I thought of making sprites with specific sizes:
(if this works I'd make sure to draw and put them close together instead of being separate)
And although when I prepare the animation I make sure to shift the position of the new sword to where it would be based on the player sprite on its own air attack animation (thus I had to modify this frame by frame,
The sword doesn't seem to follow the player, even when its game object still uses the script that makes use of the player's transform position:
I'm assuming something else has to be changed frame by frame, but what could it be? Is there a way to align or anchor a smaller sprite to follow the pivot of a bigger sprite?
All rotation or changing of sprites is done relative to the sprite's Pivot Point.
When you currently swap your sprites, your sword looks like it is rotating on it's blade rather than the handle.
Change the Pivot point to the handle, and it will do most of the work.
The rest is just making sure the handle of the sword follows the character's hands.
I would like to create a script (2D game)which can detect Player collision with tile from Tilemap named "Middle" and slow player. Problem is I dont know how to extract Tiles position from Tilemap in c# script.
Can i check that Player position and Tiles positions?
I would just make a trigger that encompasses the region that you want to slow player on and have one method in the player move script that lowers the player move speed and is called on entering the trigger and one that increases the player move speed and is called when exiting the trigger instead of positioning. I would also look into terrain and how you might use it with tile maps
click here for gif show of what I want
I want to remove mesh of object when user click on object and also remove its collider to make another object fall from that removed mesh area...
I am using unity since last month so I don't have much experience and knowledge, please help me...
Creating the destructable ground particles
One way to achieve whats shown in the gif is by creating a prefab of e.g. a circle collider that is instantiated in the area of where the dirt is in your gif. It acts as a "ground particle" and keeps the objects above itself.
You instantiate a lot of them in the area so it acts as a big collider although it is actually a whole array of smaller colliders.
Implementing the interaction logic and deactivating the ground particles
Ater that you implement the functionality of dragging the mouse over the ground particles, removing them. That is also not difficult. Shoot raycasts into the screen at the postition of the mouse (remember to use Camera.ScreenToWorldPoint) and get the collision information (confer to https://docs.unity3d.com/ScriptReference/Collider2D.Raycast.html). With the collision information you can get the reference to the instance of your ground particle(raycasthit.other.gameobject) which is then disabled through script(gameobject.setActive(false)).
created a prefab for door and added the prefab doors to the scene. This prefab door has an animator. The problem is when I try to change the animator x,y,z position on the second door in the scene it changes the first door.
I tried duplicating the doors and changing the position x y z but it changed the animator for the first door.
I just have a script that play the animator.
The expected result should be that I can drag and drop doors as needed without creating individual animators for each door. It looks like i need to create animators per door there is and also this probably will require me to create new scripts per each door. It seems awkward since I should be able to add doors and just chaning the position x y z in the animator.
The problem is that their Animator component uses the same AnimatorController asset which uses certain AnimationClip asset references for it's states.
I don't know if there is an easier way for achieve but I would do the following:
For what you want you would have to copy the AnimatorController asset (CTRL+D) as well as the AnimationClip asset you want to change.
Then in the cloned AnimatorController click on the according State you want to change and in the Inspector reference the according cloned AnimationClip.
Now you have a copy of the AnimatorController using a different AnimationClip but with the same states, traditions etc. so you can edit both animations and controllers individually.
finally in the Animator component reference the according AnimatorController for each prefab.
The remaining problem maybe is now that for the future if you change the States, transitions and especially parameters you have to do it in both AnimatorController assets individually.
That is perhaps not because of an animator, but a specific behavior of animation in Unity. Animation animates transform property according to parent, as far as I understand. So the first parent of your prefab is captured, and its transform property is used for animation. But I'm not exactly sure about this explanation - the actual behavior is covered under the Unity's source code. A common solution for this that I found is to create a parent or container inside your object's prefab. I don't know why it works, but it works. Perhaps because the parent of your animated object is now always the same.
Parent can be just an empty game object. So you make your door prefab, place another empty game object into this prefab, make your door a child of this container, set 0 for all coordinates of your door according to container and for the container itself. Now you can add an animator component to your object, which you want to animate (not the container), and animate it inside the prefab scene. After that you can place the copies of this prefab (container + your animated object inside) wherever you want inside your game scene - all animations of copies will proceed independently.