New answers tagged

1

the reason those things happen is because Unity's is limiting your FPS and that process tells you by how much its limiting it, since regular machines can reach as high as 60 FPS anyway theres no need to use 600 FPS CPU and waste all that power for nothing. the best you can do to solve that annoyance on the profiler is to just deselect Vsync from the ...


0

Set your player object's position at Start(). Changes in your LevelManager script: void Start () { player = GameObject.FindGameObjectWithTag("Player"); //Get current checkpoint from file if(emptyFile) { currentCheckPoint = vector3.zero;//or default position } player.transform.position = currentCheckpoint.transform.position; /...


0

Reduce the radius scale value as needed. Tweak how near you want the particles with the value.


0

To avoid this, instead of using "Size over lifetime", try setting a curve in "Start Size" in the same menu where you set the lifetime and the speed of your particle system. If you can't see the curve and instead are given the option to input a numeric value, click on the black arrow to the right to set it to "Curve". I'm not sure what's the difference ...


1

It is a little unclear what you are trying to do. If those points you created are empty GameObjects and you want them to be child objects of the prefab then you simply drag the prefab into your scene and then child your points under the prefab. Then all you have to do is hit the apply button in the inspector on the prefab parent and those points will then be ...


0

I found a good way around. You can use DistanceJoint2D, get the reaction force and build your own spring model by doing F/K = x where x is the distance travelled away from the natural distance and K is your spring constant.


0

Your question is pretty unclear. If you want to use your Android device to control the game, you can set up a connection with Unity and your device through USB, using the Unity Remote app: https://play.google.com/store/apps/details?id=com.unity3d.genericremote&hl=bg That way you don't have to wait for it to build and push to your device for every small ...


1

There are multiple ways to test a game, two most used are: unit and integration testing. For unit testing you're testing the inner workings of the game, without actually running it. You can do this for specific modules which have dependencies abstracted away (e.g., logic that computes the Quest XP you get, based on a given set of factors; whether a given ...


5

The best way to do this depends on a few things. I'm going to assume the following - if any of these are incorrect, please let me know and I'll update my answer: You want the closest enemy that is anywhere to the right of the player within a certain range, even if it is at a different height You want true distance, not just the one that is closest in ...


0

Maya experience here. Use a plane or cube to insect with your object. Use boolean operation like UNION,difference, etc to get this.


0

An easy way is to use GUI. Have a big square about 16x times the size of the screen with a circle in the middle of it. This is so if your playing on the TV, you wont see the stuff behind the background.


0

I've been proposed for using awesome Clipper library. It is exactly the thing I need. "For constructing the union of 2D polygons you can use Clipper library."


-1

Also, you can use CompareTag. Firstly, you must to add tag your game objects. Then: public class PlayerClass : MonoBehaviour { void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("OtherGameObjectTagHere")) Destroy(other.gameObject); } } } Please check this out https://docs.unity3d.com/ScriptReference/Component....


1

Assuming your enemies all have colliders, could you not simply fire a 2D Raycast https://docs.unity3d.com/ScriptReference/Physics2D.Raycast.html in a straight line to the right of your player and return the GameObject of the first collider it hits?


-1

Made it work by assigning a "Left Side" tag to the enemies on the left and a "Right Side" tag to the enemies on the right. After that I find the closest enemy on a particular side by checking the distance from the enemy to the player and returning the closest one: private GameObject FindClosestEnemy(string side) { GameObject[] enemies = GameObject....


2

All the left enemy are in lower value in x-axis position. Objects on right side are on higher value. Subtract main character's x value from enemy's. Positive results are for enemies at right side.


0

In the profiler capture it looks like SetPass and Triangles increase rapidly. Multiple cameras and render textures indeed can cause that because the scene has to be rendered multiple times.


0

Why just slow down the animation? If you want a slow-mo effect, just slowing the animation means everything else is still going to move at normal speed around you. For that, I would recommend lowering Time.timeScale, which slows down time for everything, including the physics engine. And to answer your question, neither. The best way is to use ...


0

well I can tell you from my experience that for me the SpeedTree's caused that. what the profiler is saying to you is "I have to wait for rendering to end before i call for the next frame update" therefor you get this bottle neck that chokes your application and that's why it uses 0 ms. there is a tutorial made by Unity regarding the Profiler and at the ...


1

So, what we have. Developer from the VS Tools for Unity team said that it is one of their most voted feature requests. And it's surprisingly not trivial to fix, they are working on it. However, I found some script which can use.. I found it on russian unity community. Great thanks to DbIMok. Also he posted this script yesterday on forum.unity3d.com ...


1

The thing is that with your list you dont know if the element is a weapon or a apple. It's just a GameItem. To be able to use the weapon specific properties you need to retrieve the element and cast it back to a Weapon. For example the update in inventory manager will look like this. void Update() { if (Input.GetKeyDown("a")) { ...


0

Fixed by setting Linear Drag in RigidBody 2D at 1.1 (value depends on gravity, etc), which damped the fall speed and now the objects don't accelerate with time when falling. Rotation can also be damped by setting Angular Drag to the appropriate value.


1

I'm giving you how I did this in java before I switched to Unity. Perhaps you can use it in c# with small modifications: So lately I did it this way: screenWidth = getResources().getDisplayMetrics().widthPixels; screenHeight = getResources().getDisplayMetrics().heightPixels; But I used to do it this way too (probably deprecated): Display display = ...


3

Alternatively to SP's suggestion, you can also add events to the Mecanim animator now. Take a look here: Then you can script it in, if you prefer this method. I have personally not used this feature yet, I just noticed it. There doesn't seem to be much information in the docs about it yet.


2

You can put the particle object as child to the main object and animate enable/disable the child in the animation tab. It's editor only.


1

How is your surf defined? In addition to lighting shader, you must modify it for material properties. Here's a modified example that uses red color instead of texture from http://docs.unity3d.com/Manual/SL-SurfaceShaderLightingExamples.html Shader "Custom/CustomLight" { Properties { _MainTex ("Texture", 2D) = "white" {} } ...


1

While I don't know for sure what these two games do, this is how I would do it: Have a Canvas set up with a child GameObject (which can be a prefab) holding all Game Over UI elements. This starts as disabled In the UI GameObject have a script which listens to OnEnable and fills out the relevant info (stats etc) Have a Game Controller that controls the ...


0

It seems to me that what you're doing has the correct basic form. But I think rigidbody.inertiaTensorRotation needs to be taken into account, though I'm not 100% positive on this either. I would argue though, that it must be that rigidbody.inertiaTensor is diagonal with respect to some arbitrary coordinate frame, while rigidbody.angularVelocity is most ...


1

If I would implement it in Unity I'd do a dedicated scene with a GUI to show whatever is needed. So in the main scene I would have some script not destroyed on load of a new scene (with DontDestryOnLoad(GameObject go) method) which have all the infos you want to display at the Game Over stage. You could also handle it in a whole scene with variables to ...


1

Following Unity documentation at the moment this is the following supported .NET lib and their versions. http://docs.unity3d.com/410/Documentation/ScriptReference/MonoCompatibility.html it has been mentioned several times that once Unity5 gets stable they will start adding more compatibility with newer versions.


4

It looks like you have 2 halves to 2 different solutions for this, so I'll explain both possible solutions and let you choose the one that best suites your needs Solution 1 Initiate a bullet instance and remove the health from enemies the bullet hits In your GunScript fire a bullet when the mouse button is down (this is half the code you already have) ...


0

Alright, thanks for the answers, but I found a decent solution. Honestly, I'm amazed I didn't think of this before. It seems ridiculously obvious. Anyway, the OriginLaser code remains untouched, here's the Redirect code: using UnityEngine; using System.Collections; public class Redirect : MonoBehaviour { public bool isActive; public OriginLaser ...


2

So long as your 'Text' object contains a Text component, this will work as expected. You may have replaced the Text component with your TextController script, or it was removed some other way. Alternatively, you could change your script as follows: using UnityEngine; using UnityEngine.UI; public class TextController : MonoBehaviour { public ...


1

This link looks interesting and provides almost that what I need, maybe it can help somebody too http://forum.unity3d.com/threads/animfollow-active-ragdoll-is-now-free-to-download.220812/


2

If you just want bumps and scratches, you can do things like use effects and deform the vehicle mesh and you wouldn't need a large collection of objects. Assuming you want to have bits fly off in a super realistic fashion and have it look awesome, then I think the easiest way is to do what you already suggested. Have a collection of objects that can detach ...


0

You can add the new script directly on Visual Studio on your intended directory in Unity. In that case you will not need to reload. But you will have to do something else. New script in Visual Studio will have some namespaces that used default. You may change or remove them. You will have to add using UnityEngine;at first for Unity related privileges. You ...


0

I fail to see what your problem is with making child objects. Just make two objects as children of your "body" object, make a script saying: public GameObject body; OnTriggerEnter2D(Collider2D other) { body.characterInQuicksand = true; } Attach it to whichever of the children is supposed to have it, assign the variable body in the inspector and you'...


-1

I think you can use GetComponent<Collider2D>().name to determine the current collider being used in OnTriggerEnter. I did a quick test with this Debug.Log(other.name + "hit" + GetComponent<Collider>().name); and it seemed to work ok as long as the triggers did not overlap.


1

You might have some success checking the Collider2D.IsTouching method in your OnTriggerEnter. void OnTriggerEnter2D(Collider2D col) { if (weaponCollider.IsTouching(col)) { /* Weapon */ } if (sightCollider.IsTouching(col)) { /* Sight */ } } IsTouching is polled against the last physics update so it should be pretty light weight. However, if your ...


1

If I understand your question correctly this can be done using a bit of vector math. I've created an example in Javascript so please keep in mind that many of the mathematical operations I'm doing here can be done in Unity really easily using the built-in classes and methods. The ball will follow your mouse when you hover it over the window. I recommend you ...


3

Libgdx is a free game library that supports java and can be deployed to Android and iOS. You will definitely be able to use a lot of your existing code and, depending on how you implemented your Android game, you may even be able to convert many of your draw calls to the Android canvas directly to draw calls in Libgdx. Libgdx definitely has a steeper ...


0

Instead of hard restrictions you can use opposing forces. You want to simulate a rubber band between the two objects. That sort of force can be simulated by applying a push every frame that equals "distance to object" to the power of "your rubber band's springiness". If you want to increase the effective distance that object A can travel away from object B ...


0

Well, I stumped our local unity expert also, but we did a debug session in my office and afer about an hour, we found out it is not the code. The Unity IDE will report console messages even focus is off the window. But our test program was an external exe (Blaster.exe) which is a console program. So it looked like the messages were arriving and the update ...


1

I had issues with PlayerPrefs() on Tizen device. Same game Worked great on Android and iOS. It's good practice using XmlSerializer or Binary Serialization. They have better control when dealing with lots of data like in your case.


0

Yes, because PlayerPrefs are VERY unsecure. If you get into the habit of using PlayerPrefs to store data, even for games where it doesn't matter, then you'll run the risk of doing it when it does matter, such as with an online multiplayer game or some such game where cheating would make a big difference. The reason it matters is because they are extremely ...


0

First you have to get all the textures used for whole terrain. From those you can get the texture you want to modify or change. Use TerrainData.splatPrototypesto get textures. Then change the color properties to give it a darker look or change the texture.


1

See the trigger pressing input. If it's pressing keep the value in a Boolean. The code will be like: if(pressing_trigger) //trigger values are [0-1] so pressing_trigger is true when trigger value is greater than 0 (zero). { //your acceleration code } Go to xbox/ps trigger setup


0

This is actually pretty easy in Unity, as Vector3 has a helper method called Distance Assuming A, B, and C are all GameObjects, you're using C#, and measuring the distance to A, your method can then look something like this: public GameObject Closest() { float distToB = Vector3.Distance(A.transform.position, B.transform.position); float distToC = ...


2

Ok, this is how I did it. Set asset serialization mode to force text Create a empty animation clip containing the Image.sprite property. Open up the new and old animations and copy everything bellow -curve: and pptrCurveMapping: from the old one to the new one. Enjoy your new animation that works with UI images.


0

It is up to you, but on android at least it is very easy to reset these things on your phone. Most of the time it is best to save things that you do not want to lose externally so that the user cannot manipulate or delete it. I am not positive how easy it is to do on iOS, but on android all you have to do is go to the app in the application manager and clear ...



Top 50 recent answers are included