Tag Info

New answers tagged

0

From what I can gather from your code spawnedSphere is NOT the game object that has been spawned, but the prefab. Do this: GameObject sphere; [RPC] void SendSpherePosition( Vector3 spherePosition ) { sphere.transform.position = spherePosition; } [RPC] void TellClientsToSpawnSphere() { sphere = Instantiate( spawnedSphere ) as GameObject; } Catch ...


0

Replacing "Instaniate(spawnedSphere)" on line 3 with "spawnedSphere = GameObject.Instantiate(spawnedSphere) as GameObject;" fixed the problem. After instantiating spawnedSphere, I didn't change its value. So I was trying to add force to the prefab.


0

Instead, get the direction from the origin to the target. Instead of moving the projective towards a destination, move it in a direction. Something like: // Determine the direction Vector2 direction = (origin - direction).normalized; Then something like: void FixedUpdate() { if (CanMove) { transform.position = transform.position + ...


0

Udk is based on a shooter for that engine to prototype that type of game is better. But Unity is very intuitive and easy to work with and also has a store with a lot of tools at low price for various tasks. A very useful tools within Unity for prototyping are Action Box and Prototype. It is also essential to use the snap (sortcut: Ctrl) and snap polygon ...


1

Aras Pranckevičius explained this issue, more clearly than I am able to, in a post on the Unity Forums: GL immediate drawing functions use whatever is the "current material" set up right now. The material controls how the rendering is done (blending, textures, etc.) So unless you explicitly set it to something before using GL draw functions, the material ...


0

The only time when a mesh collider may be appropriate would be for terrain surfaces that are often not flat and it's important to give a more realistic feel to walking on the ground surface as possible.


0

Use the profiler to do detailed checks on these things. But you're best off using primitive colliders unless you really need to be able to shoot a bullet between someone's arm and his side, and possibly miss. For most purposes, a simple pill shape is good enough for character collision.


1

The usual implementation for this is to have only a MaxMove function, and negate the value returned. You only need to remember the top level move, although remembering the path to the move that constitutes the principal variation can be helpful to understand the result, you only need to make the best move and re-run the search from the new position after ...


0

Here is a link to a similar question on stack using unity2d to rotate a sprite. http://stackoverflow.com/questions/20058028/how-can-i-rotate-a-sprite-in-unity-4-3. Also a tutorial on sprite's rotations and animation : http://www.raywenderlich.com/66345/unity-2d-tutorial-animations.


0

From the link you pasted we can read: Helgason puts it this way: "We're coming into a world where some browsers will not support the [Unity] plugin, but some browsers will not support WebGL. Us having both means you can cover every browser." Unity has spent two years working closely with Mozilla to ready this technology, which is being demoed live ...


2

Unity Web Player, as you probably know, is a browser plugin so it is allowed to run anyway it likes. Unity 5 will export to WebGL, and the article you linked says they worked with Mozilla to bring that technology, so they are most likely using Emscripten which is a LLVM to Javascript compiler. Several languages can be compiled to LLVM (including C# and ...


2

One approach to this issue is to examine the Collision Normal. This is a vector that describes the direction along which the other object is pushing back. Here is a minimal example of the concept. You will likely want to tune the condition to suit your needs (at the moment a corner collision may be erratic where x ≈ y). void OnCollisionEnter(Collision ...


-1

The problem turned out to be that my objects didn't have colliders. Anyways thanks for the help!


0

These are entirely design considerations and there's many ways to go about this. For starters: Instead of strict damage, give it a range. ie. the bat doesn't do "10 damage", instead make it do 8-12 and randomize it between those values. Give the enemy a chance to dodge or the player a chance to miss based upon some small percentage. This must be reflected ...


0

I 'think' I know what this is. This is not about the normals, it's about the choice of Binormal and Tangent vectors that the mesh exporter plugin chose - they are usually selected based on UV and don't consider the Winding Order of the polygon: the Binormal and Tangent have the wrong handedness sometimes, and if I remember correctly, there is a way we can ...


1

One of the followings is causing the problem : One of your colliders doesn't have a Rigidbody2D attached to it, as it says in the documentation, in order to get collisions works, one of the two object must have a rigidbody component You are checking "isTrigger" and expecting OnCollision response, if your collider set to trigger then you should use ...


1

The solution is not to disable input, it's to check to see if the user can jump. If you disable input: A. The players not going to be able to do anything. They won't be able to guide the character. They wont be able to grab ledges. Nothing. B. You'll still need to check to see when the user can jump because you'll need to know when to enable input again. As ...


0

2 Options I'm aware of. Play the same animation but set it to -1 speed. It will play in reverse. or In the OS, copy the .anim file and rename it. Then, open the new animation in Unity and physically swap the keyframes.


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 ...


2

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);



Top 50 recent answers are included