Working with Particles as a Game Object [closed] - unity3d

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I am trying to make a Liquid in Unity that Can be worked with and have functions. I am trying to make something more like Pouring water from a bottle to an empty cup where the water in the Bottle Decreases and the cup start to have water. I tried working with particle system but I do not seem to have control of the particles itself like for example when a particle collide with another particle they form a bigger particle and when an Event happens other functions to apply to them.
The game intends to be for phone platforms. I will be working with pixels.

You are correct to use particles for the water pouring effect. However, to achieve the cup filling up with water you will have to use some trickery. The water itself will have to be a plane or cube which rises or grows in size at a set interval while water is pouring or when particles collide with it. Personally I would just do a set interval, especially since it's for mobile, as collision detection on that level is expensive.
There is no way to script a particle system on the individual particle level (or form new ones). Particles are meant to be emitted and destroyed as quickly as possible. Having them form a part of the permanent scene is not a viable option for performance reasons.

Related

Unity2d shooting while running [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
When I shoot a projectile while running the projectile collides with the player, i.e. the player's collider is hitting the bullet's collider.
What is the best way to prevent this? By making a space between the gun and the projectile to avoid collision?
There are 2 ways I can think of right now.
1- You can create a selective collision script (or edit your existing one) and add an exception for the player object. So, bullets can go through the player. This is the main way to go.
2- You can use layers (or Z depth) and you can create a whole layer for bullet spawner etc. And make enemies also have targets in that layer/depth.
I don't have Unity installed on my current system right now. But I will install it when I get a chance, and if you don't solve it until then I will try to help properly.

Unity Javascript Making a Good Collider [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
So, I am working on a game in Unity and I have some issues with my colliding. The problem is that the car that I made will sometimes glitch next to the wall and wont move back or forward. even though it's not colliding. What I've done is I added 2 empty gameobjects. Named them front and back bumper and added a script that is activated when the bumpers hit a wall. If the front bumper hits a wall it can't go forward and if the back one hits a wall it can't go backwards. But this isn't really that good. I need to know how to setup a good collider because this really is annoying when you play. Also the car can go up to 50 speed.
Assuming that the car can collide at high speeds into the wall, I would consider using a specific collision detection for the car's rigidbody.
There are some collision detection methods that are used to prevent fast moving objects from passing through other objects without detecting collisions.
From Unity's documentation :
Discrete : Use Discrete collision detection against all other colliders in the scene. Other colliders will use Discrete collision detection when testing for collision against it. Used for normal collisions (This is the default value).
Continuous : Use Discrete collision detection against dynamic colliders (with a rigidbody) and continuous collision detection against static MeshColliders (without a rigidbody). Rigidbodies set to Continuous Dynamic will use continuous collision detection when testing for collision against this rigidbody. Other rigidbodies will use Discreet Collision detection. Used for objects which the Continuous Dynamic detection needs to collide with. (This has a big impact on physics performance, leave it set to Discrete, if you don’t have issues with collisions of fast objects)
Continuous Dynamic : Use continuous collision detection against objects set to Continuous and Continuous Dynamic Collision. It will also use continuous collision detection against static MeshColliders (without a rigidbody). For all other colliders it uses discreet collision detection. Used for fast moving objects.
As you can see, you should use Continuous detection for the walls and Continuous Dynamic detection for the car.
Warning : Don't forget that Continuous detection has a big impact on performance, you should only use it if you have collision issues and in the minimum possible amount of objects.

Why Isn't My 2D Box Collider Working? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
i'm making boundaries for the characters in my 2d game in unity 5. I added box colliders to the borders and my characters but the characters don't stop when they run into the other borders.
I don't have much experience of Unity 5, but probably these things work similarly than with old versions of Unity.
Colliders can be used for stopping things to go inside each other without writing your own OnCollisionEnter function.
So there must be some other problem. Check that:
Colliders are same type. 2D and 3D colliders don't detect collisions with each other.
At least one participant of the collision needs to have rigidbody component attached.
Check that is trigger is not selected on any of the colliders
Pause the game and check in the scene view that the green boxes of the colliders actually colliding
Check the layers of the gameobjects and check if they are should collide because of the layer based collision
When the colliders intersect it will trigger an OnCollisionEnter event. You need to tell it what to do after that. It could be setting the velocity to 0 in the case of a ball hitting the wall, or it could be awakening enemies in the case of a player walking into a trap. You have to define the behavior.

How to mantain informations between scene transition? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am working on temple run like game using this Kit. https://www.assetstore.unity3d.com/#/content/3292. I want to insert a room with two doors , when my player enters in the room it stops running and user can control with arrow keys , and when it leaves the room by back door it starts running again . what should i do when it collides with the door collides ?
I am doing this by replacing the scenes. I am instantiating an empty Game-object prefab in GamePlayScene when player is colliding with that i am loading HouseScene and when it is colliding with back door (in HouseScene) i am loading GamePlayScene. but the game is starting from the beginning. how can I resume the game From where I left And keep the track of Distance covered and coins collected? And also for HouseScene . Remember the points i achieved in it. Thanks.
You need to save the informations that you want to keep between your scenes.
You have some possibilities about that:
1) Save your informations in a text file and retrieve those when you load a new scene (but this way is a bit "dirty" and not recommended...the next points of this list are better solutions);
2) Using PlayerPrefs. They provide getters and setters to retrieve/store data in/from the registry of your operative system.
3) Using an object (as a container) that contains all your "global" variables (the ones that you want to mantain between scenes' transition), and invoking the DontDestroyOnLoad function on it. That way, your "container" (with its data) will persist in the entire life cycle of the game.

Is this strange behavior naturally emergent or an error on my part? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am working on a 2d game/simulation where planets composed of blocks around a core orbit around a star. They also rotate on their own, and both their rotation around the star and their personal rotation have random velocities.
The program keeps track of when light is hitting which blocks, and their temperature changes over time based on this light. It also colors the blocks differently over time based on their temperature. Hot blocks look redder, cold blocks look bluer.
In the screenshots below, both planets have a counterclockwise orbit around the star and a clockwise personal rotation. The planet to the left/bottom is rotating slowly, while the planet to the top/right is rotating more quickly. I will be referring to them as Planet A (left/bottom in images 1-3) and Planet B (right/top in images 1-3).
This first screenshot was taken as quickly as I could take it after starting the program:
Planet A developed very quickly (and retained) a gradient showing warmer blocks on the side that had been in the sun all day, and colder blocks where dawn was just rising. Planet B is moving so quickly, that it seems no real temperature difference can develop.
The second and third screenshots were taken about a minute later, and are only a few seconds apart to better show the strange "banding" on Planet B:
From watching it rotate, Planet B seems to have developed a permanently cold and a permanently hot side, despite its quick (and theoretically even) rotation.
Given enough time, it seems that all planets adopt this strange banding where one side is hot and one side is cold, regardless of the rotation.
(In the screenshot above, taken further along, Planet A is on the right and Planet B is in the middle.)
And the strangest part is that if I let it run for even longer, most planets adopt the sensible pattern that Planet A initially displayed, while some continue the strange banding pattern.