I have made a smoke particle effect that I instantiate everytime the player shoots, its working but can not be seen with the background. If I delete the background it's visible, I've tried changing the ordering layer, creating a new layer and putting it above the default, but no matter what it's still below the background. Any ideas?
Assuming you are developping a 2D game, you can use the z axis to set the distance of the elements to the camera (what will be the equivalent to the order of render)
Usually in a 2D game you will have the main camera at -10 in the z axis. So moving in the inspector the backgroun to, lets say z=5 or z=10, and keeping in you particle system in z=0 should solve your problem.
Try this easy trick and let me know if you are still facing problems.
You can check the second half of this video for a better understanding
Also, if you are making a 3D game you can go to the material of the particles and make sure that render face is set to both. I just had that problem and it was annoying me. but that fixed it.
Related
There seems to be an issue when i am using VR. The movement I make is not scaled correctly with the movement in the VR. I have to move much further in reality to go where I need to in VR. I am working on the reach with the OVRgrabbable script after finding something online that may help. I am having an issue with getting the X,Y axis to be recognized as objects. Everything else about the code seems to be ok as nothing else is underlined in red.
This image is the notif. i am getting. I am just referencing the x and y axis i think it should operate just fine
I have one suggestion, on the OVRCustomHand.prefab check the configurations on the script OVRCustomSkeleton.cs:
Make sure to check the checkboxes for Update Root Pose (only if your OVRHandPrefab is not parented to OVRCameraRig), Update Root Scale (makes the hand model size is scaled either up or down based on the user’s actual hand size), Apply Bone Translation.
This will make sure the Hand's position is referenced to your scene's global space instead of real tracking space.
Hope it works!
I have a quick question. If anyone can answer me, I will be grateful. I want to make an animation for about 117 cubes. I know that I don't need to do it one by one. I can simply make a prefab for the cube and duplicate it, but the problem is I just want to make it for the z-axis. However, the animation applies it for all the position properties. So how can I make an animation for the z-axis without affecting y and x? Thank you.
The problem is that you are animating the cubes based on the world position, so it is teleporting everything even for x axis and y axis.
You can easily avoid this by adding your prefab with the animation inside an empty gameObject, you can save it as a prefab too. In this way when you instantiate the empty with inside the cube, the child object (your cube) will move based on the empty position, so y and x will be the x and y of the empty one.
So
1 animate your cube
2 add the cube to an empty game Object
3 set your empty as prefab and duplicate it
If your animation is not sprite based, only transform based, you can use TWEENING Libraries. LeanTween is in the Unity Asset Store as free asset. It is far much faster than builtin unity animation. It is really easy to use. I used it in over 100 UI objects and it didn't even used any remarkable resource at all (FOR 2D Object). I believe that will solve your problem easily.
Hi guys i was wondering how to create a shape adjustment with two objects which specifically could be described as the independent cells, one of which is static, and the second one is dynamic and surrounded by "plasma". The movement of the active object must be controllable by the user (WSAD). Collision of the active object with the static one causes the static object to be swallen, though doesn't change it's position stays in place all the time. As the active object moves, passes the swallen object and troughts it out.
See the image below:
Player character
When it comes close enough to pink enemy it's starting to swallow it (surround by yellow thing)
Pink enemy is completely sourrounded when red circle is in the centre of both.
When it leaves enemy it takes off the yellow thing
I was wondering what is the simplest way to do it. I've been thinking about cloth, physics joints, mesh substraction (is it even possible?), some kind of animation... I don't have much time to do it. Can you show me the simplest way. Which tools and approach should i use? I'm not asking for full code or full solution only for some tips.
Tim Hunter mentioned a wonderful way, most perfect in 3D.
You can use another approach in 2D :
Inside OnCollisionEnter2D try finding hit points using Collision2D.contacts . See this reference .
Create some particle effect there.
Disable the enemy
Now play swallowing animation of the player.
At animation end, enable enemy again.
Maybe calculation is little tricky, still efficient.
I have an object which has a diffuse shader and on runtime I want the shader to switch to Diffuse Always Visible but this should trigger only if the unit is behind a specific object within the layer named obstacles.
First I tried to switch the object shader with the following code and the shader is changed in the inspector but not in the game during play. I tried placing and calling the shader from the resources and also created seprate materials but its not working.
Here is the code I am using in C#
Unit.renderer.material.shader = Shader.Find("Diffuse - Always visible");
As for the rest I was thinking of using a raycast but not sure how to handle this.
Thanks in advance
I only need the other concept now where the shader changes if a unit is behind an object!
For the trigger, how to handle it will depend a lot on how your camera moves.
To check in a 3D game, raycasts should work. Because whether or not something is "behind" something else depends on the camera's perspective, I would personally try something like this to start:
Use Camera.WorldToScreenPoint to figure out where your object is on the screen.
Use Camera.ScreenPointToRay to convert this into a ray you'll send through the physics engine.
Use Physics.Raycast and check what gets hit. If it doesn't hit the object in question, something is in front of it.
Depending on your goals, you might want to check different points. If you're just checking if something is more than halfway covered by an object, doing a single raycast at its center is probably sufficient. If you want to see if it's at all occluded, you could try something like finding four approximate corners of the object and raycasting against them.
If it's a 2D game or the camera is always at a fixed angle (for example, in a side scroller), the problem is potentially a lot simpler. Add colliders to the objects, and use OnTriggerEnter or OnTriggerEnter2D (along with the corresponding Exit functions). That only works if the tiniest bit of overlap should trigger the effect, and it only works if depth doesn't really matter (e.g. in a 2D game) so your colliders will actually intersect.
I'm using an Oculus Rift with Unity, and am attempting to allow the user to zero-out the orientation of their device when they push a key. The idea is that the camera is frozen looking in a particular direction, and when the user begins the game, whatever direction they're looking in is bound to that camera orientation. I found this forum post, but it only says to use SetOrientationOffset, but doesn't provide code.
I've tried both of the following, independent and together:
OVRDevice.ResetOrientation ();
cameraController.SetOrientationOffset (Quaternion.identity);
However, neither seems to have an effect. I've even tried passing other quaternions into SetOrientationOffset, but that seemed to have no effect.
Does anyone have a working code example?
If different quaternions make no difference then you probably have a game object set in the FollowOrientation variable. If you clear that then passing in different quaternions should have an effect. Alternatively you can rotate the thing you've set in FollowOrientation. Then you need to find the correct orientation to start in. Probably the rotation of the frozen camera is what you need.