Tag Info

New answers tagged

0

When communicating between client and server you're using RPC calls. These RPCs are possible with the NetworkView script attached to an object. For simplicity, it's easiest to attach your communication scripts (the ones making invoking the RPCs) to the same object that the NetworkView script is attached to. This needs to be done on both Client and Server. ...


0

You might want to look into Skydome - it's a Unity package that allows for animated skyboxes. http://www.pixelstudio.nl/?p=138


1

First off, use this shader for your skybox: http://wiki.unity3d.com/index.php?title=SkyboxBlended The default Skybox shader won't allow you to transition between two skyboxes (eg. one for day, one for night). The "blended" value of this shader can be adjusted in code, so adjust it over and over a little bit every frame. Meanwhile, besides the skybox you ...


0

You cited games like "Jetpack Joyride" and "Geometry Dash" so I understand you are working on a 2D game with side scrolling view. I assume the Y is up and X is right. In Jetpack joyride: - the camera is fixed - the player only moves along Y-Axis - you move transform the level and background to simulate that the player is moving, so the player speed is ...


0

today I just crossed with the same need and I can point you towards some interesting resources. Basically the technique implies: 1) blending various textures of your skybox over time: that implies writing a shader that blend in and out different versions of your skybox at different daytimes/exposures. 2) maybe you also want to blend different Lightmaps to ...


1

Make the camera object a child of the object that's moving. This is super easy and doesn't take any additional scripts. Make a script for the camera that will update its position based on a target object: Example: public GameObject targetl; public float xOffset = 0; public float yOffset = 0; public float zOffset = 0; void LateUpdate() { ...


2

I recently faced the same problem. I was creating an scrollable image gallery in Unity, where images are downloaded in real-time from the a web server. On iOS devices I was reaching very fast the memory limit (with consequent app crash). That was caused due to a very big number of www objects leaved in the memory and never deleted or released. Also a very ...


0

I think you should keep things simple in this case. The three switch system is a challenge with a solution and this Puzzle has two states, currently solved correctly and currently unsolved (or solved and then reverted to unsolved for some reason [timer?]). So you have a Boolean value and you need to store it somewhere in your game so the door could get it ...


0

You should probably let player use their own tool and allow them to mod/upload an icon for this purpose into the game. Drawing it in game, is a matter of tracking the mouse position and clicks, designing the drawing tools gui and simply adding and removing pixels at position (x, y). It is not complicated but sounds like a waste of time if you could allow ...


0

When you create a rotation matrix or quaternion from an angle, you are actually taking the sine and cosine of a numeric value in radians. Your value in degrees is being converted to radians, so 90 degrees becomes π/4. π is not something that can be represented accurately in floating point. This is where the accuracy loss is coming from. If you take the ...


1

Floating point math is not perfect. You're trying to compress an infinite set (all real numbers) into an extremely finite space (32 bits). Consequently, not every number can be accurately represented, and some numbers will suffer from rounding error. Basically, as you do increasingly more math on some particular value, you increase the chance(*) that the ...


0

Eventually found out. Turns out it was very basic. This is probably not an efficient way, but it serves the purpose. The problem was the yield return statement returns a value immediately without waiting for confirmation from the master device. To solve this, take the value and check if it is indeed the value we require, if not call the coroutine again with ...


1

This is an interesting problem. I can think of two mechanical (brute-force-ish) approximate approaches. My math-fu is not strong enough to opine if an analytic solution is practical here. I hope there is such an approach! But here’s my “just get it done” suggestions. By Gridded Area, approximate We only care about the blue area. Represent that to the ...


0

Try to get the sphere equations with respect to world space for each sphere like a sphere with radius r and centre (a,b,c) in WorldSpace Coordinates will be represented by the equation (x - a)^2 + (y - b)^2 + (z - c)^2 = r^2 then find the common portions and subtract the equations to get the blue part and any solution of the remaining equation will be a ...


0

Found the issue. You have to use tex2.Apply(); For the SetPixel() changes to take effect.


1

It's actually really simple. First you put a line renderer component on your nav mesh agent object. If you notice, there is an array called positions. So if you attach the following script to your nav mesh agent, it will create a path between the nav mesh agent's origin and the destination. var line : LineRenderer; //to hold the line Renderer var target : ...


1

From what I can tell from the Halo class documentation, lights do some magic behind the scenes to automatically create a Halo component, but hide it from the hierarchy (much like how AudioSource.PlayOneShot() will automatically create and destroy new AudioSources while hiding them from the hierarchy). It seems the Halo component is not exposed. However, ...


0

If the DLL is not a .Net assembly (i.e. cannot be loaded in the References folder) put it in the root folder (not the assets)


-1

I have the same problem. U have to set light Render priority. Click in point light (or other) in Hierarchy and in component "Light" change "Render Mode" to "Important"


0

This solved my problem. #pragma strict var pos1 : Vector3; var pos2 : Vector3; var objectHeight = 2.0; // 2.0 for a cylinder, 1.0 for a cube function Update () { if (Input.GetMouseButtonDown(0)) { pos1 = Vector3(Input.mousePosition.x, Input.mousePosition.y, Camera.main.nearClipPlane + 0.5); pos1 = Camera.main.ScreenToWorldPoint(pos1); pos2 = pos1; } if ...


1

A simple solution would be to create and empty object( Camera container ) that follows the player and have the camera as a child. You can animated the shake independently however you want with the camera gameobject as long as it's a child of the container. -- Container Object (Follow player) └ Camera Object ( do animation )


2

If you have the normal vector for the "top" face of the hex and the vector for the directional light it should be easy to determine if that hex is facing the light. Note that this will check if the hex and the light are facing each other. This will not detect of another object is in between casting a shadow over the hex. Vector3 lightDirection = ...


1

Try adjusting the Max Angular Velocity in the Physics Manager. You can access the Physics Manager by selecting Edit->Project Settings->Physics from the menu bar. The default value is 7. Maybe try a value around 100. That seemed to work well for me. You can override the Project Settings value of Max Angular Velocity for any Rigidbody by scripting ...


1

Trigger an event, or just call the change method when you change the type of terrain object. Pull you color switching code out of start and put it in its own method. Then, have start call the SetColor method, and have your code that switches terrain types also call SetColor whenever the type changes. It's not something that needs to be done every frame, ...


1

Getting null reference exception is normal since they were created in the previous scene and destroyed in the current one. To move them to the next scene, you need to call DontDestroyOnLoad. Why don't you create your assets after the scene is loaded? GameManager should be responsible for creating player and enemy objects and keep track of the game state. In ...


3

I don't think that you should go with static class members (you didn't mention language but I assume some kind of OOP) because that just hides "singleton" in a different place. Switch things around so your Game holds a bunch (map, set, list, array, whatever) of these across-room global puzzles. Make it so your rooms can ask the game about a puzzle it's ...


1

Interesting case. One way I can think of solving this would be to have an up normal on each hex tile. You would dot each hex's normal with the light source direction vector, and if the angle between them is more than 90 degrees you ignore all light calculations for the whole hex tile.


0

I had similar issue, but my character stopped at some points. After adjusting rigidbody mass and physics material friction, it worked. Maybe it will work in your case.


2

In Unity you can load any text file with Resources.Load() like this: string text = (Resources.Load("NameOfTextAsset") as TextAsset).text; After that you can use any standard C# method to split the string to parts, and Convert.ToInt32() to parse the integer from the splitted up string. foreach(string part in text.Split(' ')) { int number = ...


-1

The best option is to use a database to store your player data. What database to use is ultimately in your court and what seems relevant based on your own research. Inputting that data into a database should be easy for these two metrics simply because you're only talking about tracking the login date and timestamps of your players. Those timestamps will ...


0

You simply need a database. You store the login time and the logout time. You then simply compute and aggregate the time. This could be done continuously or whenever it is needed. Another option that is easier to implement but a little bit more resource intensive is to have all players "fire" a http request every 10 seconds (or similar) to the server that ...


1

You're destroying the object that contains the coroutine. A simple fix for this situation is to use the extended version of Destroy. // Destroy the bum after 1 second Destroy (bum, 1);


1

It's because you're going Destroy(this.gameObject) before starting the coroutine. A destroyed object cannot keep running a coroutine. A solution would be to run the coroutine on the clone object.


4

Absolutely, But not as simple as taking a return value of a normal function. First I assume your question isn't about sharing variables between two shader stages (vertex, fragment..etc) but actually between two shader (programs). Shaders are part of the rendering pipeline, every input/output should pass through the rendering pipeline and its memory is ...


0

This is my way for achieving this effect: void OnTriggerStay2D(Collider2D other) { Debug.Log("Object is in trigger"); player.rigidbody2D.AddForce (-Vector2.right*20000*Time.deltaTime); }


-1

I created a AssetStore extension that allows for easier aspect switching called AspectSwitcher. It provides a system for allowing you to easily specify different properties for different aspects. There are generally two method that most people use to switch aspects. One is to provide different game objects for each aspect. The other is to create custom code ...


0

If you have a convex shape then what you can do is perform a convex hull operation to get a list of vertices that define the edge. Now find the average position of these points to define the center. If you already have a list of edge vertices then you can ofcourse skip that step. These edge points and the center can be used to define triangles as is common ...


1

C# Version. using System.IO; void readTextFile(string file_path) { StreamReader inp_stm = new StreamReader(file_path); while(!inp_stm.EndOfStream) { string inp_ln = stm.ReadLine( ); // Do Something with the input. } inp_stm.Close( ); }


2

There's class named TextAssets which is used for text file read. http://docs.unity3d.com/Manual/class-TextAsset.html here you can find the supported file format. so if u want to read read the text file, script would be like this: class YourClassName : MonoBehaviour{ public TextAsset textFile; // drop your file here in inspector void Start(){ ...


0

There are many points you can check: does it load (import) correctly in your Unity how many polygons how many textures how many bones how many draw calls does it incur in the engine. in forward mode / and deferred mode. is it manifold does it create seams while lightmapped previous point is linked to secondary UV set unwrapping quality. does it have a ...


0

You won't get away on this one with an easy answer. The raycast method is completely flawed. Its the same as calling the object "one pixel" wide and checking if this pixel is visible or not. Unity uses a precalculated visibility matrix, composed with regular sectors of your world, and a quadratic ray cast test. Which has the same flaws but you don't need to ...


0

Forget trigonometry. Use vector math. Think of it as solving an equation: you want the position of the platform and the position of the enemy to be the same at some point in the future. So you write the equations of motion for both, and solve for the velocity of the enemy: platform_x = platform_x0 + vel_platform0 * t + accel_platform * t^2 / 2 enemy_x = ...


2

Since Unity can publish games to iOS, this would be just like making any other client server application. The easiest would be to have the iPads all connected to the same network as the host PC, but you could easily utilize the Master Server tools provided with Unity to get everyone connected. You'd likely use RPCs for most of your communications. As long ...


2

Depending on your exact needs, another possible solution would be to do a test render where you set different objects to different colors and then check for that color in the test render. However this would only be useful in pretty obscure situations; in the majority of situations I would use raycasting. I'm just dropping in this different answer for ...


5

As requested, one possible solution (with some flaws) is to use raycasting: Attaching a (C#) Script similar to this to the GameObject from which you want to check visibility would work: if(renderer.isVisible) //Check if Camera is turned towards the GameObject first { RaycastHit hit; // Calculate Ray direction Vector3 direction = ...


0

Im pretty sure the problem is caused by one point light being in the range of the other point light so, for lag issues Unity only renders one of these lights. This can be fixed by increasing the intensity of the light and decreasing the range of it.


1

http://docs.unity3d.com/ScriptReference/Vector3.Lerp.html Have a look at lerp. You'll be able to move to a position over time like this: transform.position = Vector3.Lerp( start, end, currentTime / totalTime ); Where start is the initial position of the object you are moving and end is the place you want to be once currentTime = totalTime. In your case, ...


0

You have both the current position and the last position on move. (touch.position, leftFingerPos) You can do a ray cast using these to see if there is a collision with your arrow. http://docs.unity3d.com/ScriptReference/Physics2D.Raycast.html


0

OK, I'm assuming that you're creating your random grid inside of a two dimensional array. int[,] grid = new int[5, 5]; int lastVal = 0; Random r = new Random(); for (int i = 0; i < 5; i++) { int startCol = r.Next(0, 5); for (int j = 0; j < 5; j++) //-1 indicates that the node is empty grid[i, j] = j >= startCol ? lastVal++ ...


1

This code is working fine for me to read the content in the text file import System.IO; var filename="data.txt"; function Start () { var sourse=new StreamReader(Application.dataPath+"/" + filename); var fileContents=sourse.ReadToEnd(); sourse.Close(); var lines=fileContents.Split("\n"[0]); for(line in lines) { print(line); ...



Top 50 recent answers are included