Tag Info

New answers tagged

0

public class ClickTest : MonoBehaviour { //public GameObject red,red2,yellow,yellow2,MainCamera; // Use this for initialization void Start () { } // Update is called once per frame void Update () { if (Input.GetMouseButtonDown(0)) { Debug.Log("Pressed left click, casting ray."); CastRay(); } } void CastRay() { ...


1

Here's how I've approached this situation in Unity in the past: I create a custom shield shader that accepts some number of vector parameters (typically 3 or 4), each representing a recent hit. The xyz components are the position of the hit in local coordinates, and the w component is the intensity. Within the fragment shader, I compute the object-space ...


0

The story like this.... Unity Input Manager pain is lasting for years. On Unity site you can find request on the forum for InputManager programmatic access dating from 2004, and feedback from 2009 with state planned today 2014. Below are some of the problems. 1) Ingame input controller mapping. Unity have user interface for mapping predefined bindings ...


1

Memory leaks in Unity can occur on several places. But to help you in the right direction, one of the most common leaks in unity would be the Texture/ material leaks Imperfect loops (for, foreach, while, etc) These leaks are often hard to track and can lead to crashes. To properly chase them down you first want to make sure that you have no warning ...


1

I'm fairly certain, though someone will no doubt prove me wrong, that you can not change individual elements in the mesh arrays of vertices, triangles, uvs etc. That is why when you work with procedural meshes you always update the entire array at once when you've finished modifying it. The reason for this is that mesh.uv gives you a copy of the mesh uvs ...


1

It looks like you have your score working using Time.time as the counter. I thought it may be helpful to explain what was happening when the code in your question is executed. When game starts and the Start() method runs it calls StartCoroutine (FeetScoreCounter()) When FeetScoreCounter() runs it immediately yields for one second, then after that delay it ...


0

This was the correct solution, where it converts score (float) to an integer.


0

This can be done with a short timer. It is probably not a problem if the animation doesn't start immediately when the character starts falling. public float delay = 0.1f; // Animation starts after 0.1 seconds of falling private float lastCollision = 0.0f; void Update() { if(Time.timeSinceLevelLoad > lastCollision + delay) { animator.Play ...


1

TextMesh[] child = GetComponentsInChildren<TextMesh> (); This line (and the three after it) is always getting the first three TextMeshes in the parent object's child hierarchy - not the hierarchy of the newatom you've just created. That means that each time you create a new atom, you're overwriting the labels on the first atom you created, leaving ...


2

I just tested this using the following code: void OnCollisionEnter( Collision collision ) { this.enabled = false; Debug.Log( "Collided with " + collision.gameObject.tag ); } void Update() { if( this.enabled ) { Debug.Log( "Enabled" ); return; } Debug.Log( "Disabled" ); } "Enabled" was displayed until the object ...


0

I think this document from the Unity help should be useful. Look to the diagram at the bottom of the page. Physics and collisions are processed before the game logic so if you disable an object during collision it will become disabled after its next update.


1

For states, I usually use Enums, and then do a switch statement within the Update method. Enabling/disabling components is probably easier than adding/removing them. If you need to listen for or be ready to execute a method that should only happen within a specific state, check the state at the start of the method. If the file gets too long and confusing, ...


1

The coroutine itself will pause, but the code that called StartCoroutine() will keep going. So in this case, WaitTime() will pause but OnTriggerEnter2D() will keep going. What you probably want instead is for the entire button logic to go in the coroutine. Then it won't matter that OnTriggerEnter2D() keeps going, since starting the coroutine is all it does. ...


1

Your WaitTime Coroutine will not pause the evaluation of the following code. The Coroutine will be kicked off and logic will immediately continue. Your Coroutine is waiting 3 seconds and will call that print function wherever it resides but that's all it will do. You should probably go with something like: private float triggerEnterTime = 0; void ...


3

You want your webserver access to go through HTTPS; that will encrypt the traffic so people in the middle can't read it.


0

I think it would be useful for you to try this program "bmglyph" http://www.bmglyph.com/ You can generate a character set with the font you like and export the font atlas in unity native format and in Cocos2D format (the format used by NGUI). Then you can look at how the program generate the .fnt and match it against what you already have and see if you are ...


0

Unity's Entity-Component-System implementation isn't an ideal model on which to base a custom ECS. Unity favors ease of use over strict adherence to the ECS paradigm and made lots of trade-offs to serve that end. Where Unity falls short of a pure ECS is the lack of separation between data and logic. In a pure ECS components contain only data and the logic ...


0

If you could generate a texture which is about the normal on the surface of the object you want to show the shield. There is no need for shaders. First, you need to prepare a cellular texture like the reaction in the picture, which should be transparent. Then, about the reaction when hit by the beam. Then, you need to prepare a(maybe several) dome for ...


3

It seems that something is going wrong when you create the textures for the individual characters. First, if we look closely, we see that it's not just the o, g and 3 characters are badly positioned: As Petr Abdulin points out: The base coordinate for your sprites is "left,bottom" (classic Cartesian) which is correct. Your renderer assumes ...


1

Movement should never be dependent on framerate. Bob Nystrom wrote an excellent summary of how to write a game loop that is independent of framerate. Check it out here. He starts with the most basic game loop then makes incremental improvements, discussing the motivation behind each iteration. I've added his code here but you should really check the article ...


1

You need to separate your games logic from display logic. Game logic should run at some fixed rate (e.g. 100 ms). Display should query the state of the game and display it at unconnected rate (e.g. 10-20 ms). That way your display performance never affects the game.


4

The reason you are getting this behaviour is because of coordinate system. The base coordinate for your sprites is "left,bottom" (classic Cartesian) however all offsets in fnt files are assuming inverted Y axis (drawing from "left,top" of the sprite). So instead of (you may notice this gives correct align, but on the top, i.e. g goes up instead of down): ...


3

I can't add a comment because my reputation isn't high enough, so this isn't really an answer. I thought the o's were offset differently as well, but when I used a ruler it turns out all three o's are on the same baseline. It is just an optical illusion from the dropped 'm'. In you code sample for extracting the glyphs from the font texture you use the ...


0

Yes, unless you click "Apply" in the editor any changes made to a prefab instance are considered as overriding the prefab and do not affect either the prefab or the other instances of the prefab. Once you instantiate the prefab you can change all aspects of that instance at your discretion. You do it the same exact way you manipulate any other object.


0

It depends on what type of collisions you want to resolve and who controls the wolf. Wolf is NPC If you want to resolve collisions with static environment you should think about using NavMeshAgent and bake static geometry to navigation mesh (so, that kind of collisions will never happened). If you want to collide wolf with other units with simple colliders ...


0

I had this same problem. I found out you have to call this from OnAnimatorIK, not an update function.


0

It was as easy as adding this to my IEnumerator Dead: if(hasPlayed == false){ audio.PlayOneShot(popAudio); hasPlayed = true; }


0

For a character object, mostly a capsule collider is enough. But ofcourse it depends on your game. Primitive colliders are more efficient compared to mesh colliders. You can use Profiler in Unity Pro versions and there's an internal profiler in Android and iOS for Indie versions. Although the pro Profiler obviously gives you detailed analysis, the internal ...


2

In my experience writing collision detection mesh-based collision (triangles versus other triangles) are the most expensive for of collision in physics engines (PhysX, Havok). Unity uses PhysX internally, so this is no different. Because each computer and platform perform differently, exact numbers cannot be provided, but generally speaking the relative ...


0

I found the problem. I had a wrong value on the vertex for an edge. My edge table said that for the edge 10 the vertex were 2 and 4 when they should be 2 and 6. Thank you for your time.


0

There are a few values that are crucial to multi-camera rendering in Unity: the culling mask, the clear flags, and the depth value. All three are mentioned in the camera component manual. mainCamera depth is -1, and NGUI Camera depth is 1. Unity draws cameras in ascending order. If you want the NGUI background behind the scene, you should flip those ...


0

To expand on crancran's answer, I will share our experiences with the ECS we use at work. Each component has the ability to be registered with a list of that component type. For example, our ModelComponent is registered with a ComponentList in it's create function, and removed in it's destroy function. Each frame, in the update loop, different systems are ...


0

Scripting is very different for various reasons from programming using C++ and very similar in the same time. Similarities: You'll often write function, classes and expressions You instruct the Engine what to do during the game / menu state. Differences: You need to compile C++ and you don't need to compile a script. C++ often offers lower level ...


0

Scripting usually referred to programs, which are processed by interpreter (virtual machine). Programming usually referred to programs, which are compiled to machine code. I think there is no reason to discriminate scripting and programming, since both scripting and programming environments are usually Turing-complete, so they are equally powerful.


0

Scripting and programming are used interchangeably in certain contexts, but they are certainly distinct. The clearest difference is that scripting is a type of programming in which you are controlling the behavior of complex objects. With scripting, you do not generally specify the structure of the application, but rather you manipulate the objects within ...


1

Scripting is a subset of programming. Programming in udk means you are also creating functions, mathematical expressions, logic and conditions etc yourself. When you say you are using a scripting language then basically it means you are calling functions, creating objects, setting the resources and much more batch work and sometimes AI too. Python, perl and ...


0

It sounds like you might be using a prefab or parented item. If that is the case, you can access each component by using the gameObject hierarchy list in the editor and the various options in the inspector (this is where the transform and rotation values are located). Each object or component of a prefab has a position, rotation, collider, and renderer ...


0

If I understand your problem correctly, it is as follows: Problem: You have no way of knowing when your progress bar stops scaling/progressing in x value. You would like to position a red bar (for player feedback) at the end of the progress bar only if it stops scaling/progressing. If this is correct, I think that I may be able to help. Answer: It seems ...


0

thank you for your answer. I've implemented the portal in my game. I use OverlapArea to check if there are objects near the portal and duplicate them to next portal. And if the objects leave the portal, I delete all objects that are not visible by the camera. You can see the effect here.


0

So I have found the solution at last :P the problem was the position of the Touches were in pixels and i took them as for screen coordinates. So to fix it, float resultant_magnitude = Info.half_height / camera.orthographicSize * (prev_touch_position - t.position).magnitude; replace the above by this : float resultant_magnitude = Info.half_height / ...


0

Make sure all NGUI components' layers are the same, like "UI". Attach your UI's NGUI panel with box collider. Add a script "InputManager.cs" and rewrite function GetMouseButton() like: public static bool GetMouseButton(int button) { if (UICamera.hoveredObject == null) { return Input.GetMouseButton(button); } else { // If click/drop ...


0

(Posting my comment as an answer) If you take the 3d plane for your cell and the line for that south pole, and find the intersection point, then you could use LookAt for that point. You would also want to handle the case where the plane is parallel to that line, in which case you could rotate the plane to a predetermined angle, to orient it correctly.


1

Unity is a very powerful and very complex game engine. Most games only use a small fraction of its features. But no matter how much of it is actually used, a game which uses the Unity engine must include the whole engine which is a hefty 10MB chunk of additional filesize. For a very simplistic game like Flappy Bird, using such a huge engine is usually ...


2

It's possible to use an Android "APK Expansion File" so that additional content is downloaded at runtime the first time you launch it. Next, if you have very few graphics that always repeat (if I remember well Flappy Bird has very few graphics assets) they can be compressed in the .apk and expanded in-memory during execution. Graphics and art assets are the ...


0

If they get blurred be aware to import them in "Advanced" mode and disable "Mip Mapping" generation. Next check if any level of compression or filter is applied. Sometimes the filter tend to eat details of your image (try Point Filter or Bilinear Filter with small Anisotropic Level) Also the best result is obtained when your textures are painted "pixel ...


1

Basically you have to balance - reduced number of draw calls - small memory footprint at runtime - small application package size (as already said) I suggest to organize textures/sprites that are printed in the same scene in "Sprites Atlases" and keep the max resolution of atlases around 1024x1024 or 2048x2048. This, combined with some good scripting as ...


1

There are essentially two things to consider when thinking about the drawback of a larger texture size; performance and build size. Large textures are more complex to render so have higher requirements of the hardware. Large textures also make the build size much larger which may be an issue when considering the mobile market - mobile devices have less ...


1

I've found a workable approach. I grabbed the DS4Tool source and copied the bits I needed into my Unity project so I could read the reports from the device directly. (That's the NativeMethods class to interface with Kernel32.dll, the device enumeration from HidDevices, and reading the report from the HidDevice class. I cut out the rest to keep things as ...


2

I think there is a simple/dump way of achieving this (which I have not tried yet on code). Assets: You have one background image You have an image with the same size as the background but painted in the colours you want the border to be painted in (referred to as "border-color" image) You have your regular sprites You have a 1-bit (or 8-bit) outline ...


4

Your gif is from Path to the Sky (TIGSource), and definitely uses a pixel shader to achieve that particular outline. For a guide to using custom shaders in Unity, have a glance at their shader reference page. There are a few tutorials and samples that should get you started. However, I agree with @DMGregory, you can create a similar looking effect with a ...



Top 50 recent answers are included