New answers tagged

0

One way to solve this for opaque lines is to render a circle at each joint. The circle needs to have a diameter equal to the line width. This requires a few extra vertices to be rendered, but looks really nice. You also can then get rid of the shared normals between the joints. This still requires that you write your own rendering code instead of using the ...


0

You'r approach is rather strange, but stick with it an learn it's faults / strengths because creating it your way is a great way to learn. Below is the same concept just cleaned up a bit. Remember that in your setup, the box object has to be offset so the left side of the box is at the same position as its parent. This can be done with sprites setting the ...


1

If I get you right, one way would to add a script to your Bomb Prefab that implements the OnTriggerEnter and OnTriggerExit method. There should also be a collider attached, the collider should be marked as trigger. If it is a mesh collider, make sure it is also convex, otherwise the OnTriggerEnter/Exit methods will not be called. In OnTriggerEnter/Exit you ...


1

You can take a look at this project which implements a software render. This revision shows how to draw triangles (but filled with the same color). I modified triangle method so that it accepts 2 colors and draws gradient. void triangle(Vec2i t0, Vec2i t1, Vec2i t2, TGAImage &image, TGAColor c1, TGAColor c2) { if (t0.y==t1.y && t0.y==t2.y) ...


3

This might be the correct expected behaviour for the code you've written. Let's run through some math. I'll assume for the moment that you're using Unity's default FixedUpdate rate of 50 Hz and that your character has a mass of 1. If I press right on my stick (on the ground), my character gets an x velocity of 5 m/s. If I do this in the air, then since ...


0

The key is knowing current world rotation, you need to maintain it as you rotate e.g.: double worldRotation; void rotateWorldLeft() { worldRotation = (worldRotation + 90) % 360; } then, when moving the character, just Rotate the Vector2s along e.g.: if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A)) { ...


-1

I solved the problem! It can easily be fixed by setting generate lightmap UV to true in the import settings of the model.


0

private Animator animator; // Use this for initialization void Start() { animator = this.GetComponent<Animator>(); } // Update is called once per frame void Update() { var vertical = Input.GetAxis("Vertical"); var horizontal = Input.GetAxis("Horizontal"); if (vertical > 0) { animator.SetInteger("Direction", 1); ...


0

This can all be done in the Controller. All you need to do is create another state. In my example I created a walk and walk backwards: The walk state is just the walking animation, it takes in a float parameter called "Speed" and transitions from idol when speed is greater than zero. The walk backwards state, which is simply the walk animation played ...


1

It is the feature of unity. There is a small little surprising button does exist at the top of Game tab, called "Maximize on Play". You can disable this feature by pressing it again.


0

Please take a look at this; if I'm on the right track, I'll expand it and add narrative. You'll draw a single terrain prefab over and over, having it morph based on the descriptions fed in via the per-instance buffer. Example description elements: Matrix worldMatrix; UINT terrainTextureArrayIndex; Pickups can be handled similiarly. Draw a single cube ...


0

Attach this script to the "UI Text prefab" that you are creating Dynamically. using UnityEngine; using UnityEngine.EventSystems; public class TextClick : MonoBehaviour,IPointerClickHandler { #region IPointerClickHandler implementation public void OnPointerClick (PointerEventData eventData) { if (eventData.button == ...


0

Design some level blocks with combination of obstacles coins etc. (Maintain a parent child relation). Make a LevelGeneator script which will contain a Array of Transform or Gameobject. Assign the level blocks to the Script object in inspector. Randomly take a Transform and give it some force and make SetActive(true). If its still not clear, let me ...


1

Well, in Unity you can check GPGS and Game Center login status via Social.localUser.authenticated. This will return a bool value that indicates either the user is logged in or not. true for logged in and false for logged out. void PrintUserStatus() { if (Social.localUser.authenticated) print("Player is logged in"); else print("Player ...


0

If you have several platforms connected in Unity your character might sometimes, (not always) slow down/stop. There are 2 fixes that might work for this : 1. Circle Collider If you have a box collider on your moving object/character, the corners of the collider might collide with the corners on the connected platforms, causing the object to slow ...


0

If it's a bitmap font, you need to make sure that the letters in the sprite sheet are white so that colors will be applied correctly with Unity's default text shader. Most tools, including Unity's "Create Editable Copy," create black letters, but this will lead to the exact symptoms you describe. If you have an existing sprite sheet with black letters, you ...


0

Try changing your assignment to debug[id.xyz] = 1;


0

SmoothDamp suits well for situations where the value it's moving towards is dynamic, like transform values, and you want it to retain an organic sense of motion and agency. This is due to SmoothDamp factoring velocity in its algorithm. Lerp is fine for most other cases.


4

The mechanical difference is that Lerp is linear, while SmoothDamp follows a sigmoid function. See How to Lerp like a pro and Smoothstep for more in-depth explanation and graphs. In terms of which one you should use, that varies from product to product, situation to situation. SmoothDamp-style is often more pleasant to the eye, especially for slower fades ...


0

It would be great if your question was more specific, like dragging a game object or something. However you can use Interface to solve the problem. The demo code is given here. If you have questions regarding how to use it feel free to ask. using UnityEngine; using UnityEngine.EventSystems; public class AnswersManager : ...


3

using UnityEngine; using System.Collections; using System.IO; public class ScreenshotNow : MonoBehaviour { public RectTransform rectT; // Assign the UI element which you wanna capture int width; // width of the object to capture int height; // height of the object to capture // Use this for initialization void Start () { width = ...


6

Check if Touch TouchPhase is Stationary, which even says will be set only if: A finger is touching the screen but hasn't moved. I suggest you also read up on the Touch.phase property, which exposes the TouchPhase for the specific Touch. The link also has examples on how to use the phase. The other option is to check the deltaPosition of the Touch. If ...


1

So, I did some googling and according to another question it should work online with one exception : Basically there are no hard limits, with exception of WebPlayer, which is limited to a 1 MB. Source : http://answers.unity3d.com/questions/182755/playerprefs-lmitations.html


0

I suppose that when you create the UI Text objects, you are adding to them a RectTransform component, just like I answered you here: How to dynamically create an UI text Object in Unity 5?. Knowing that, one simple and very efficient solution for what you want is to detect if the desired mouse button was pressed AND if mouse cursor is over the RecTransform ...


-1

I ended up using Physics.linecast from the _charface.transform.position to the intersect point.


0

The only point of trying to approximate this sphere is to filter which pixels to modify. Try this from the reverse direction: 1) Render everything (no sphere) normally using FragmentShader1, transforming with ViewProjection: return tex2D(_MainTex, i.uv); 2) Activate an Opaque BlendState so we overwrite whatever was just drawn. 3) Activate ...


0

Unfortunately, I haven't used Photon so I can't help on that front. If you are only making an Android game (and thus, you don't need to go cross platform game play) then you should look at the play-games-plugin-for-unity which is put out by Google.


0

Unfortunately that's how the cross-domain same-origin policy works. The RFC 6454 Capter 3.2 says: two URIs are part of the same origin (i.e., represent the same principal) if they have the same scheme, host, and port.


1

I'll throw my singleton into the mix. It checks off all four of DMGregory's criteria (see his answer). This has a lot of stuff that may not make sense. It is just covering Unity specific corner cases, and persists between scenes. It is tried and tested, and the most current version can be found on my Github. Enjoy! Usage is by having your script extend this ...


4

I think what you are looking for is something like following: GameObject CreateText(Transform canvas_transform, float x, float y, string text_to_print, int font_size, Color text_color) { GameObject UItextGO = new GameObject("Text2"); UItextGO.transform.SetParent(canvas_transform); RectTransform trans = ...


2

As your desired image reflects that you want it in 2D, so I have modified your current script which would draw a path from your given Game Object, decided start position, mouse or finger position would be the end position. Other than that you can specify number of elements should be drawn on the path. Well, have a look and give it a try. Comments will also ...


0

Setting the width is a different operation from setting the points. You just need to use the SetWidth(a,b) method: gameObject.GetComponent<LineRenderer>().SetWidth(2.0f, 1.5f); However, the width is applied over the entire line. This likely won't work very well for your simulation of a pencil line. You'd probably want to create two LineRenderers. ...


0

Add [DisallowMultipleComponent]before your class to make sure you can't add more than one instance of it. example: [DisallowMultipleComponent] public class Toolbox : MonoBehaviour Also, I recommend reading DMGregory's comment before implementing this, it might be better to just create a static class instead.


2

If you are looking for a quick&dirty solution for debugging, you can still use the old Unity 4 solution. Implement the OnGUI event of any MonoBehavior you have always active to call the GUI class to add some UI element to the current rendering frame. void OnGUI() { GUI.Label(new Rect(10, 10, 100, 20), "Hello World!"); } If you want to use the ...


2

Instead of pathing from each new enemy to the player as they spawn of the player moves significantly. Do a floodfill from the player to fill the entire map with how far the player is from each tile and which way he is. Then for pathing you just follow the arrows. The floodfill Will only need to update the neighbours of the tiles whose value changed after ...


2

1 do you mean you want change the uitext dynamically? If you want to change it, first u have to attach your script to gameobject. Then bind your variables. Tutorials could be found here transform.gameObject.GetComponent<Text>().text = "123"; 2 If you want to create uitext which is not in Hierarchy beforehand. You could use GUI. GUI Label Put ...


0

You probably run the pathfinding algorithm every frame. It should only happen once, when the enemy spawns. If your area is destroyable, then you will need to do it every time an obstacle is destroyed.


3

You need to bake a navmesh first.


1

I can't type in a location without all the selected boxes going there (so if I type a y-location of 12, every single selected box will be crammed on top of each other on y=12) This issue is easy to fix: Select all boxes and duplicate them. Put them inside new empty parent GameObject. Translate that GameObject by needed distance. Take boxes out from ...


1

In C# when a struct is accessed via a getter (like transform.position), the compiler won't allow you to modify a member, because it has no sense to do that, because a getter of a struct return a brand new struct that you have to reference first. If you don't your brand new struct will stay inaccessible...


0

Well, it is most probably because you have your Trigger (Sphere) collider attached to the same object where your Sword would work. So it is showing the same behaviour as sword hits the enemy, because of same object and script. What you can do is , Make a parent gameobject in which player and another gameobject should exist as children. Attach two scripts ...


3

You want the 2D version of the method: OnCollisionEnter2D Collisions with a Collider2D/Rigidbody2D won't send the "OnCollisionEnter" message, only "OnCollisionEnter2D"


1

It's not a perfect solution (I hope others can suggest general-purpose tools for this), but I usually do this with keyboard shortcuts: Ctrl + D to duplicate the currently selected objects select all of them Hold Ctrl and drag the translation handles to move them, snapping to 1-unit increments So I start with one object, dupe-move it to get 2 one unit ...


1

Let's assume your Unity project is in: C:\Users\me\Documents\Unity Projects\My Voxel Project\ (If you don't already have a project, start by opening Unity and clicking "+ New" when it asks which project you want to open) Now, copy the contents of the tutorial to: C\Users\me\Documents\Unity Projects\My Voxel Project\Assets\ You can create additional ...


0

You assign the object you find to the wrong reference; this should do the trick: GameObject Particules; void Start() { Particules = GameObject.FindWithTag ("Particules"); } void OnTriggerEnter() { Particules.AddComponent<Rigidbody> (); }


0

While Draco18s mentioned in comment about good practices. But one more thing is considerable is that you declared Particles on class level. Then you are creating new one and assigning in the scope of Start, which will destroy as soon as pointer leaves the Start braces. So in OnCollisionEnter your Particles object is still empty. Try to remove declaring in ...


1

Input.GetButton() instead of Input.GetButtonDown() The former checks to see if the key is currently down and outputs true for every frame during the press. The latter checks to see if the key was up last frame and down this frame (that is: true for exactly one frame until released again).


1

I am no game designer or have any qualification but I have an idea for a realistic tactical semi turn based ship to ship combat system. Ideally it would be full 3d movement but it is likely easier to explain in 2d. So you would have the area of space between the 2 ships. This is measured in light seconds. Therefore at the start lets say there is a 120 ...


1

you can publish different versions of your APK targeting different CPU architectures, with the same package name: Build an ARMv7 only package and an x86 only package with different version codes. The versionCode of the x86 package has to be higher than the one of the ARM package. When publishing, send both of your APKs to the developer console. Note that ...


-1

To answer all your questions: The two languages supported by unity are currently javascript and c#. In unity 4 was a 3. one, boo, but like 5% of the developers used that language, so they removed it to be able to focus on other aspect of the engine. javascript Don't let the name confuse you, this is really far from the pure javascript. Unity provides some ...



Top 50 recent answers are included