Tag Info

New answers tagged

0

Looking at your comments, I think you want a smooth movement towards the target. To do that, your step is too small, since Time.deltaTime will usually be 0.01666 at 60 FPS. So your step will actually be very small and you will move little before you reset the position again. Instead, you can use this Coroutine instead of Vector3.MoveTowards: IEnumerator ...


0

If you use Unity superior or equal to 4.6, you can use UI/Selectable-interactable. The button will cannot be used if interactable is set to false. For example: public Button instrumentButton; void Update () { if (canPlayInstrument == false)) { instrumentButton.interactable = false; } }


0

First off, there's inconsistency in your "DelayedSpawn" method name. When you call StartCoroutine its called "DelayedSpawn", but the coroutine method seems to be named "DelayedSpawnC". Second, your "spawnB" method seems to select an object at random and the Z position is dependent on which object it chose. According to your description, sometimes it works ...


0

This has been discussed a few times in Unity's forums. This thread has a long discussion about the issue, and this and this Unity answers posts. If you don't solve it and everything seems to work fine, I suggest submitting a bug to Unity. Remember this is a warning, so it is possible that even though you see it everything will work well. Usually it happens ...


-2

K..................................


0

When in doubt profile. Time it and see.


0

Unity's serialization system doesn't support inheritance for custom serializable class. In order to correctly serialize fields of a polymorphic type it must be derived from MonoBehaviour or ScriptableObject. For your example BaseClass should extend MonoBehaviour to make it work. In addition, custom serialized class references won't be resolved. This means ...


0

Check the file name of the script and make sure it's the same as the class name. I've had this problem before after renaming a script through the editor.


0

You either have a compile error in this script, or you have one in a different script. If this is the first time you're trying to use this script, the entire solution needs to compile before Unity knows about this new class you're introducing. Locate your error and correct it before trying to add this script. It could be a compile error or something like a ...


0

http://answers.unity3d.com/questions/46283/way-to-get-all-object-with-a-certain-componentscri.html Here's what you're looking for. You want to find all components of this type in the scene. Since Unity 5 you should be able to find interface in the generic versions of Find* or Get* methods. You should probably only do this in Awake, Start or some other ...


0

Wouldn't it be simpler to just use some integer state logic to drive the match comparisons? For example you could just keep track of each Tile's state and colour and do numerical comparisons instead of interrogating the actual texture of each gameObject? This has the added value of using a single Texture Atlas to store your tile textures and then just map ...


0

Looking for a list of lists? List<List<Rectangle>> ListsOfRectangles = new List<List<Rectangle>>(); Use it like this: ListsOfRectangles.Add(new List<Rectangle>()); ListsOfRectangles[0].Add(new Rectangle()); foreach (Rectangle R in ListsOfRectangles[0]) { //iterates through first list in ListsOfRectangles }


1

Try making your texture 512x512 that could be the issue since your texture is 400x400. XNA error logs state that the texture should be resized to a power of two.


1

if(Input.GetMouseButtonUp(0)) this.gameObject.SetActive(false); This will hide the "button" completely from your scene until you decide otherwise. I recommend you go through the docs so you can figure out these answers by yourself.


1

I played the game. Each of the separate games appear to be "maps" loaded in the same basic surgery game. Each "map" seems to have a pre-determined script that the player follows, or else. Each button/tool is given a ToolID. For the heart-surgery "map": toolsNeeded = {1,3,2,6,3,5,1,0}; //Loaded from "map" currentToolIndex = 0; //New game while(patientAlive ...


0

Below code will do what you want. You will need to save and load the value of "DateTime lastPlayDate" between sessions. using System; public class GameManager : MonoBehaviour { DateTime lastPlayDate; void Start() { lastPlayDate = DateTime.Now; } void Update() { DateTime currentTime = DateTime.Now; ...


0

If target is a transform, you want it to be target = pickedNumber.transform;, (no transform.position). If target is a Vector3, you want the next line to be ball.transform.position = Vector3.MoveTowards(transform.position, target, step);, (no target.position). I assume it's the first one, because of the wording of the error, but the second one is to show ...


1

One approach that can be taken with multiple color transitions is to leverage a Gradient. By exposing a public variable of this type a developer an use the Inspector to launch the Gradient Editor to design a gradient containing any number of colors. This editor allows you to use a the unity color pickers, fine tune placement of the color/alpha keys and ...


9

let Arr be an array of Colour let N be the number of colors in the array let t be the 0..1 float value float scaledT = t* (float)(N-1); Color prevC = Arr[(int)scaledT]; Color nextC = Arr[(int)(scaledT+1f)]; float newt = scaledT - (float)((int)scaledT); finaly you can use Lerp Color.Lerp(prevC, nextC, newT)


1

There is few ways to do this. Store information of last gifting time to: Local device ( pc, phone, table or what ever is the gaming device) Cloud service. However, this is harder method and requires the actual service hosted at somewhere in internet. File writing method is quite simple to do. Store time to variable When game exits, write time to ...


0

How about you write your own version, which leverages Color.Lerp()? A very simple version that takes 3 colors, and puts the second one right in the middle could look like this: Color Lerp3(Color a, Color b, Color c, float t) { if (t < 0.5f) // 0.0 to 0.5 goes to a -> b return Color.Lerp(a, b, t / 0.5f); else // 0.5 to 1.0 goes to b ...


0

I feel like there may be a better solution. The only reason I would see to lerp from color to color is if you were wanting to continuously change the hue... http://en.wikipedia.org/wiki/Hue Here's how to convert HSV to RGB: http://en.wikipedia.org/wiki/HSL_and_HSV#From_HSV With this you can use HSV colors, simply change the hue, then convert to RGB. ...


1

public float every; //The public variable "every" refers to "Lerp the color every X" float colorstep; Color[] colors = new Color[4]; //Insert how many colors you want to lerp between here, hard coded to 4 int i; Color lerpedColor = Color.red; //This should optimally be the color you are going to begin with void Start () { //In here, set the array ...


2

The WaitForSeconds() command does not run/return when Time.timeScale is equal to 0 because it relies on Time.timeScale. I'm assuming because you mention pausing, you set the Time.TimeScale to 0, then call "yield return new WaitForSeconds(15f)" and unpause with Time.timeScale = 1. You can use Unity's Time.unscaledDeltaTime, which is how much real time has ...


2

Let me rename the vars (for clarity): Vector3 pos3d = new Vector3 (1f, 2f, 3f); Vector2 pos2d = new Vector2 (1f, 2f); Answer It is because of the section pos3d + pos2d of the line. This part is really ambiguous while the += is not. Let me clarify why one and why the other. Analysis 1 In this line transform.position = pos3d + pos2d; the compiler ...


6

Full issue message: error CS0121: The call is ambiguous between the following methods or properties: UnityEngine.Vector2.operator +(UnityEngine.Vector2, UnityEngine.Vector2)' andUnityEngine.Vector3.operator +(UnityEngine.Vector3, UnityEngine.Vector3)' Unity provided a way to implicitly convert a Vector3 to a Vector2 and vice-versa. This causes an ...


0

Many moons ago when I first dabbled in pathfinding algorithms I used the following site to help me to first understand the basic fundamentals of how a simple pathfinder is meant to work, and what it's trying to achieve : http://www.policyalmanac.org/games/aStarTutorial.htm The A* algorithm is quite popular and suitable for most pathfinding needs in gaming. ...


0

Clear both rt's to Transparent before drawing the texture to them. Since you will be explicitly clearing them to Transparent[Black], you should specify: new RenderTarget2D(..., RenderTargetUsage.PreserveContents); to prevent XNA from clearing rt's rendertarget (to not Transparent[Black]) when you set the current rendertarget to NULL. When you draw them ...


0

Ah, then I may be confused on game structure with XNA... If loadcontent and initilize in the main game class can only be called once, They are called once per device creation not per game start. If you re-size the underlying Windows window, the device is, and all content should be, explicitly destroyed. then do I call my other classes loadcontent ...


1

Your problem is transform.up = TowardOrigin;. I didn't know you could actually set transform.up until now, since it's actually a summary of a more complex state of the object -- its rotation. Setting it tells Unity to orient your object along that axis, but doesn't tell Unity to keep transform.forward as close as possible to what it used to be. You're ...


1

Why not draw a semi-transparent black sprite in between the background and the yes and no buttons? For example something like this: If you had a scene that looked like this: Then you could simply draw the semitransparent mask on top and have it look like this: Then all you'd have to do is draw the buttons on top of the mask while the rest of the ...


1

Simply set the object's Transform.position to Vector3.Lerp(Vector3 A, Vector3 B, percent completion


3

Original RenderTexture image on the left, edited Texture2D image on the right. public class PixelChange : MonoBehaviour { public RenderTexture renderTexture; // renderTextuer that you will be rendering stuff on public Renderer renderer; // renderer in which you will apply changed texture Texture2D texture; void Start () { texture = new Texture2D ...


0

Try using something like this ... http://docs.unity3d.com/ScriptReference/RenderTexture.html ... by that I mean more specifically this ... http://docs.unity3d.com/ScriptReference/RenderTexture.GetTemporary.html ... presumably combined with ... http://docs.unity3d.com/ScriptReference/Camera-targetTexture.html ... to render what a camera sees to a ...


0

float4 color = tex2D(s0, coords); float4 land_color = tex2D(land_sample, coords); You are sampling the "world" using the SpriteBatch quad's UV's. The blue UV's are used to sample the color-texture; the yellows are used to sample the world-texture. A Draw() parameter and/or the camera matrix is inverting the Y-axis, so it is using the bottom corner as (0,0) ...


1

//Everything normalized shipRight = shipForward.Cross(target.Up); shipUp = shipForward.Cross(shipRight); The cross-product is perpendicular to both vectors. For this diagram, I gave both spheres random orientations. The left view shows the steps from an arbitrary, third, perspective; I couldn't find a better alignment, so you'll have to take my word that ...


2

It should be: private List<List<GameObject>> blockData = new List<List<GameObject>>(); It needs to know what kind of List the variable is.


0

This method will save you some resources create a sphere for your planet with a small height map, make your texture 2.5k for compact pixels add sphere with transparency + weather around the planet. that is the best way to fudge planets for games just ask bungie


2

The way Google does it The way Google Maps does it, is indeed by having multiple levels of detail. Moving through these levels, tiles will get smaller and smaller. Fitting a 2k texture on a tile that contains a full continent, will give you less detail than fitting a 2k texture on a tile that contains a small neighbourhood with only a few roads. It is ...


1

Don't get discouraged on your first, but this is a very low-quality question for this site. The "best" answers for this will be to pick one, implement it, then profile it if/when you encounter performance problems. You may be trying to solve a problem, today, that you'll never even have. In general: Using a library from someone else has the generic ...


1

First, lets get this out of the way, aiming for 100k user is ridiculous for semester project. Aiming for 100k users playing in one physical server is insane for any game. XNA is not an engine and no where near as high level as Unity. XNA just provides nice set of code, gathered in library with all the necessary "boilerplate code" done. It is DirectX for ...


1

If you want to space game where you can get close to the planets you actually need to model the planets in a significant more realistic fashion, just using one humongous texture is not going to cut it. Now it really depends on the level of fidelity on what you want to do. But the problem with the scale of planets, when they fill your almost your entire ...


2

(removing the sides of the cube does not count) Sorry dude, that is what you have to do if you want this to be efficient and work every time. The reason you're getting those lines is slight depth buffer inconsistencies (also known as z-fighting). The sides of the blocks are almost at exactly the same depth as the tops of the nearer blocks. Ideally, in ...


3

From the docs on transform.Translate: public void Translate(float x, float y, float z, Space relativeTo = Space.Self); If relativeTo is left out or set to Space.Self the movement is applied relative to the transform's local axes. (the x, y and z axes shown when selecting the object inside the Scene View.) So because you have not specified a ...


0

It seems like your transformations might be accumulating over time. As repeatedly "stepping forward" and "rotating around your axis" will cause the black bar to walk in circles. I'm unfamiliar with Unity, but there are some general approaches that might be applicable: You could try recalculating the object's position from its starting position, rather than ...


1

The Getting Started page for building Unity apps for Winows store specifically says Unity doesn't support networking on Windows Store platforms. It does mention that WWW functions work correctly though. If you're desperate, try porting your networking to HTTP.


0

Make them separate game objects with a shared parent node, so you only have 1 instance of the script on each object. Put the Animation component on the parent, and you can animate each child independently.


0

Check X any Y boundaries for the respective objects. So, basically you want your object's X value to be be greater than RED's X value and less than BLUE's X value (so it's horizontally between them), and your object's Y value to be less than the max Y value RED/BLUE (whichever has a greater Y, less than that). When it passes the lower Y value then you ...


1

I've already answered a similar question, with identical goals, over on Stack Overflow I'll repost it here for convinience: (NB - all code is written and tested in Java) This image shows the top left corner of a hexagonal grid and overlaid is a blue square grid. It is easy to find which of the squares a point is inside and this would give a rough ...


0

I found it a little bit difficult to follow the entire thread of your question. However at the most basic level, in a simple FSM you could either just query the current state of your StateMachine (i.e. assuming its a singleton manager class etc : StateMachine.Instance.GetState ) and then do the necessary long-winded if or switch statement logic depending on ...



Top 50 recent answers are included