Tag Info

New answers tagged

0

I believe it is, because otherwise an object which is clicked won't be able to determine when the mouse button is released again. The best alternative I can think of is raycasting. Put all objects which can possibly be in front of the tiles in the Ignore Raycast layer. Then, from a "manager" script, cast a Raycast from the mouse cursor's position into the ...


0

What you have here is a circular dependency, and it is considered bad (your post illustrates why). What you should have is a class above both teams that deals with stuff inbetween them.


0

You can't. You cannot run two different bits of code at the same time (with multithreading you can but not for what you want to do). You're going to have to refactor your code so that you create both the objects and run the initialization code that depends on the other object at a later date (simply create a new method and call that when they've both been ...


2

this problem is divided into two situations´╝Ü first: sword, this thing can be just parented to the bone, then it will move with bone; second: cloth, in blender, you need to use the same armature, then create two different cloth, and rig the cloth mesh to the armature. in unity3d, read this article: ...


0

http://docs.unity3d.com/ScriptReference/GameObject.FindGameObjectsWithTag.html Returns a list of active GameObjects tagged tag. Only Find GameObject at root of scene, No recursive.


0

It takes memory to keep it alive and update its position and other properties. But it doesn't consume computer/mobile graphic resources since it is not visible. So yes, it does consume memory resources but not graphics resources like a visible Game Object does.


0

Instead of creating a regular game object, create a UI Image ( New >> UI >> Image/slider/etc.). The new Unity UI system has specifics that aren't available to normal game objects, so when you make them public they need an exact type to be dragged onto them. This has been my experience at least, hope it helps.


0

You have options: If all 3 bullets should hit the target within a certain radius, add a small random amount, in world-units, to a random player-local axis (X or Y), when calculating the angle. shootVector = player.pos + randomDriftInWorldUnits - myTransform.pos; If the 2 extra bullets can spread too far apart to hit the player, even if the center bullet ...


0

Update runs once per frame. Using while in the update script like that, in English reads like this: "Once for this frame, while the mouse button was held down for this frame, move the camera and stuff". The reason why this does not work well is because, the mouse will be in a 'down' state until the next frame, and it wont go onto the next frame until the ...


0

I'm sure it supports this, although I don't know how to describe it in terms of where and what to click within Unity. Using instancing: Create a single, correctly-sized tile with 4 vertices (and 4 indices) Edit: The index buffer is initialized and uploaded only once; it should be filled with the same 4 indices over and over, tileCount times. It's ...


0

You are creating a rectangular "viewport". The first line sets the width and height of the rectangle. The second line translates it to the correct tile. If all of your tiles are 128 wide and the texture is 1024 wide then each tile is 128/1024=0.125=12.5% of the overall width and 128/128=1.00=100% of the overall height. You can think of this as applying a ...


0

Unity uses an entity component system, so you should probably think of your scripts as somewhat general components to be added to an entity. You can specialise your components further (for example, Projectile can extended into AoEProjectile). Here's the wikipedia article on the subject: http://en.wikipedia.org/wiki/Entity_component_system


0

WaitForFPS isn't really an issue (it has a specific purpose in attaining the target frame-rate of your game). Is your camera getting moved in the LateUpdate Callback? The most common reason for camera jitter in camera movement scripts is using Update, which is causes the target's movement to happen after the camera's movement is updated, leaving it always ...


2

Parent the objects to bones and they will move with the bones.


0

A lot of answers are mainly considering the graphics aspect of your question. The fact is they will take up various resources, and how expensive they are compared to drawing the object isn't fixed. It's not as uncommon as some answers implied for your components to be making more expensive operations than drawing does, but you can minimize how many ...


4

I think you should also know about Frustrum Culling, or hiden surface removal: http://en.wikipedia.org/wiki/Hidden_surface_determination This is an important bit of optimising a game, because even if your objects are not inside the frustrum at a given frame (i.e. visible), some draw calls (shaders) are still launched for them, therefore decreasing ...


0

you can disable MouseLook for a small amount of time? using invoke to reactivate after "disableTime" float disableTime = 0.5f;//0.5 second disable void reactivateML() { mouseLook.enabled = true; } ... mouseLook.enabled = false; transform.Rotate (-5, 0, 0); Invoke("reactivateML", disableTime); ...


1

what about: Animator[] anims = new Animator[number_of_animators]; anims[0] = anim0; ... if you mean to have an array editable inside the editor you can declare it as public and you will specify inside the editor its size and you will be able to drag and drop elements into it just like this: public Animator[] anims; this is to be declared just as ...


3

The short answer is "yes"; anything that is ready to be used in your game is taking up memory. The other thing to consider is the cost to your frame-rate: 5 objects, with 5 separate textures, drawn separately require state-changes in-between. You may be able to save some memory by unloading textures that aren't used. By loading all of the separate ...


13

What you want is a memory profiler, Which Unity does have. Here: http://docs.unity3d.com/Manual/ProfilerMemory.html But your assumption is mostly right, if a gameObject is not visible to the camera it is not drawn, and it uses less resources, but it still must consume some. The gameObject still exists in memory, including all the textures, models scripts ...


0

Anything that is in a program consumes resources; You don't think programs run on simply hopes and dreams, do you? The question should be how much resources does a game object consume, and to that end I think this is a pretty solid answer: http://answers.unity3d.com/questions/280455/how-much-memory-a-gameobject-consume.html In short, they consume ...


0

I using this code for downloading some pictures in my apps you can use it with some changes i never had any problem with this code string uri; //Source Path string fileName; //Destination Path HttpWebRequest request_ = (HttpWebRequest)WebRequest.Create (uri); HttpWebResponse response_ = (HttpWebResponse)request_.GetResponse (); if ((response_.StatusCode ...


0

Essentialy A* needs to be configured with what is not an accessible tile , so you can configure that by making an algorithm using gameObjects 'surface taken on the terrain then calculate the tiles to avoid at runtime .Then add it to the closed list (if there is not something for that already )


0

The right way is to make a prefab , you allocate that prefab as an Object , then whenever you want to instantiate just use the reference of this Object and cast it as a GameObject. ex : private Object prefab; public static GameObject Create(void) { return (Instantiate(prefab , position , rotation) as GameObject); }


1

That seems like a very basic task, if I understood correctly. Obviously, if one node can fit only one blinky, then your function has to satisfy the following condition: Amount of blinkies <= amount of nodes. And there're several ways to loop until you have placed a blinky. One would be just decrementing the iterating variable: if(randomNode.walkable) { ...


0

Here is a simple solution: Instead of calling Destroy(yourObject) everywhere , replace that with a CustomDestroy function what has the following code: public static void CustomDestroy(GameObject o) { o.transform.position = new Vector3(100000000.0f,10000000.0f,10000000.0f); Destroy(o); } Setting the position before you destroy an to 'infinity' ...


0

If you want the code in your OnTriggerExit to be called inside the OnDisable method as well, simply encapsulate the code into a function of its own, and call the function from both methods. void OnTriggerExit(Collider other) { CommonTriggerExitCode(); } void OnDisable() { CommonTriggerExitCode(); } void CommonTriggerExitCode() { //Code to be ...


3

You can use the OnBecameInvisible callback for that. Just implement something like: void OnBecameInvisible(){ // disable or destroy gameobject } The method will get called when the object isn't being rendered by any camera anymore. This also includes cameras from the Unity-Editor. So if you're running your game and have the Game and the Scene view ...


1

Hello I suggest you use Raycasting to test if the camera is directly pointing to the light source. The ray will go from the camera into the front vector direction, Once you get the RaycastHit, you can check the name, the tag or even use Layer Mask to selectively ignore colliders. If you want to apply the effect even when the camera is not pointing directly ...


0

This question has so many answers its unreal but here goes ... I have been working on a voxel based solution that uses a fractal noise source for the data to generate at the lowest level of detail a perfect sphere and then a texture to wrap around it. It's really just an extension of the method documented over at ...


2

you might try having the on enter adding the enemy to a 'target list', and on exit/killing enemy have that entry removed from the list. using System.Collections.Generic; // lets use use the magical 'List' array List<GameObject> targetedEnemies; // List arrays let us add and remove stuff later, // that is, they do not have a maximum capacity and won't ...


1

Perhaps this is what you are looking for: transform.forward = transform.up;


1

If you don't care about the interior being painted in, there's a really simple solution. First, draw all circles in black. Next, draw all the circles again in white, with a smaller radius - basically subtract a border width from the radius. The result will be a constant thickness black border around a white area. You could maybe even use this black / white ...


0

At the end of your update step you have lastInput = currentInput;, which will happen even if the character is jumping. So in essence when you get into the FixedUpdate step your lastInput variable will always be the same as the currentInput variable. By the looks of it, Vector2 currentInput = new Vector2( Input.GetAxis("Horizontal"), ...


0

Ok, as I said in my comment above, I have come to believe my problem is a genuine bug in Unity 4.x. I haven't tried Unity 5.0 yet, might be fixed there, but I couldn't wait anymore and I just hacked a non-polymorphic solution. I'm going to not green-check this answer in case some hero out there magically comes up with the right solution, but for the ...


0

I had the same problem. I've made some experiments with different types of sprites (single and maps). I've tried to add transparent border to my sprite map in Photoshop, but it didn't work. Then I separated the sprites from my sprite map. It worked for me. It seems that the problem is with sprite maps.


0

Don't use character controller, instead of it use rigidbody+capsuleCollider and then control rotation and forces with script as Wardy stated. Here is a video that may be helpful: Video


1

You probably could draw, and save 'intersection points' any point where two circles draw a point at same location. Then use that set, knowing that inside and outside changes when an intersection occurs. You would then only need to check any one point between two intersections to know the status of an entire arc between any two intersections. Fewer checks ...


0

Depending on exactly what you are trying to achieve, I might recommend not scaling anything (either the camera or your sprites) and instead just worry about the differing aspect ratios (eg. moving things to the edges of wider screens). Things will scale to fill the screen automatically; the graphics won't be pixel-perfect anymore, but with the ...


1

Looks like the options are ... Implement your own version of the rigidbody script. Make your world a whole lot bigger and rotate it under the player as they move rather than rotating the player round the world.


0

Turns out I need to call the method by name with a string instead of the method itself to stop the coroutine. StartCoroutine("AttackEnemy"); ... StopCoroutine("AttackEnemy");


1

I want to update this considering the new shader stages recently added. Someone more familiar can probably be more thorough, but: such as a car's front end destroyed when it hits a wall? The new stages allow you to more-cheaply enhance low-poly models. You could generate an entire vehicle from a single cube's-worth of vertices (8). Given a relatively ...


2

Draw each circle on some memory, then after all are drawn, set the inside of every circle to zeros, clearing any intersection lines. clarification On some memory is meant to indicate separate texture Set to 0 is meant to indicate set to transparent. setting inside transparent on second draw sequence is fill with transparent color with fillcircle of radius ...


-1

Or draw your circles as filled, then trace the edge that would work also. tracing edges method would only be computationally a better method with a very large number of circles. Where edge trace is faster then second set of drawing.


0

If any point is closer to the center of any circle then the radius of that circle clip it. Although you would probably want to find the intersection points where any two distances equal to the radius of a circle, from any two different circle centers are equal, to get clean edges where intersection occurs. basically any point inside another circle is ...


1

maybe you don't get the reference to the right animator, to TEST (or DEBUG) define it public public Animator anim; , run the game and watch in the inspector if it has referenced the right one. If the animator you need is attached to the same object where you attached the script it should work, but if they are not attached to the same game object it doesn't. ...


0

You've already got most of the setup. What you could do is just control the Campfire from the other collider inside the Collision method [untested code] : // in CollectableItems.cs //... if (other.gameObject.tag == "CampFire") { if (count > 0) { var campfire = ...


0

Essentially what you're looking for is Unity's Retargeting of Humanoid Animations. http://docs.unity3d.com/Manual/Retargeting.html Basically as I understand it, as long as the rig you imported with the models/animations meets Unity's Avatar and muscle definition criteria for a humanoid character, then you should be able to use that rig and subsequent ...


-1

I see two solutions to your questions. 1) Use the SendMessage(string methodName) function. It will call the given method on every components of the gameObject. (More info here: http://docs.unity3d.com/ScriptReference/Component.SendMessage.html). Here is an example: public class Script1 : MonoBehavior { public void DestroyShip() { /* ...


1

The GameObject car is not set to anything. That means it's null. This is exactly what the error message is telling you. Just because you happen to have a prefab named 'car' in your Assets folder doesn't mean you can name a variable car and expect Unity to know you're talking about the same thing. See my answer to your other question to learn one way to ...



Top 50 recent answers are included