New answers tagged

1

Rather than calling GameObject.FindGameObjectsWithTag every frame, you could just call Gunner_SpeedIncrease() within OnTriggerEnter when the trigger/collision happens. void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag ("BulletProgressionObject")) { Destroy (other.gameObject); Gunner_SpeedIncrease (); } }


0

You could use unity's Gizmos to draw cubes and spheres. Script Reference. void OnDrawGizmos() { Gizmos.color = Color.red; Gizmos.DrawSphere(this.transform.position, 1); }


0

I am having the same difficulty in getting the trackpads to recognises button presses. But for getting the controller ID i used a fairly straight forward method (in C++ but should be transferable to unity/c#) uint right_controller_id = (uint)hmd->GetTrackedDeviceIndexForControllerRole(vr::TrackedControllerRole_RightHand); uint left_controller_id = ...


0

When making games, I typically support resolutions between 5:4 to 16:9. The best way I found to ensure maximum object coverage on the screen is to optimize for 3:2 and then adjust the camera's view along the axis that minimizes the amount of extra space. So if the game is in landscape mode and is being played on a 5:4 device, the width would remain static ...


0

Well I finally figured out the issue with some help from here and Reddit. Basically I was trying to send the raycast from the model's (the child) forward and that was the wrong forward. So I changed the third (2nd) line of code in the update statement to Ray ray = new Ray(Player.transform.position, Player.transform.forward);. This basically makes it so that ...


1

To get the bounds of a group of objects, you need to get the bounds of each object in the group. For each axis, you compare the maximum and minimum bounds of each object. The maximum of the local maximums is the global maximum, the minimum of the local minimums is the global minimum. i.e. Global_X_Max = Max(item1.bounds.max.x, item2.bounds.max.x,...) ...


1

Grab all the .bounds properties of all the items, and figure out what the maximum and minimum values are.


0

When you have a collision, do a CircleCast (or BoxCast, depending on the shape of the collider of the colliding object) from the center of the colliding object with a size equal to its own collider, a distance of 0 and a layerMask setting which only covers the polygon collider. The resulting RaycastHit2d object will tell you the closest point of the polygon ...


1

A Couple things to check: 1) Transform.forward may not be the direction you actually want to shoot the ray. For example if this is a first-person game, the direction the PhysGun is facing (transform.forward) may be totally different than where the camera is looking, and in that case you would probably want to shoot the ray from the camera. 2) Have you ...


0

Usually when you want to have "Zones" in unity, you use game objects with Colliders with isTrigger activated. There are two strategies you can use here. Either you surround the track with colliders to detect when the vehicle leaves the road (OnTriggerEnter) or you place colliders on the road and detect if the vehicle is still on the road (OnTriggerStay). ...


0

I use this and it seems to work on different devices. The motion of putting the phone down gives me a value for the delta x of -0.5041921 on a samsung galaxy and a -0.5021868 on a Nexus 5. using UnityEngine; using UnityEngine.UI; public class GyroController : MonoBehaviour { // public Text x, y, z; public Dice dice; public GameManager ...


1

A world-space canvas is rendered as a 3d plane-mesh in the game-world, which means it is overlapped by other 3d objects. But to solve this problem you don't need a custom shader. You can do it with multiple cameras with different culling masks. When you have multiple cameras in your scene, each camera will be rendered separately. The culling mask decides ...


0

You're going to need a custom shader for your World Space UI objects that has it's Render Order to Overlay and has ZTest turned off. Also your World Space ui does not have to be a child of a screen overlay canvas( that's not how it works) This is a copy of the Default UI shader with the necessary changes. Should do the trick. Just make a material with this ...


0

Maybe your problem is due to your are using a prefab to have all enclosed, so once you click on this prefab in your project folder the values will be reset to its default values. The solution is dont use a prefab, put your script in a empty game object. Cheers!


1

A MonoBehaviour is always added to a GameObject with AddComponent. Unfortunately AddComponent will always instantiate a new object, which means that a MonoBehaviour can not be a singleton. However, MonoBehaviours can use singletons. When you would like to add a singleton-component to multiple game objects, create a separate MonoBehaviour which is ...


0

Have a look at ScriptableObject . This'll allow you to persist this type of information over multiple sessions.


2

Unity can be used for your simple text based game, which you should not have any difficulty making with its new UI features. Though the people who have mentioned that the a feature rich engine such as unity is not required to make a simple game like that. I would say that there is no harm in using it. It also makes deployment to platforms relatively easier ...


0

It sounds like it greatly depends on your game and where you want to go with it, but here's my 2 cents: I don't think you should include translation or rotation into the animations themselves. Rotation should probably be saved for orienting the character in the proper direction (in Street Fighter this is usually left or right). Baking in the animation ...


1

Assuming you'd like your game's levels to be edited by either a non-technical game designer or QA team, I would actually recommend none of what you suggested for the actual level editing portion. Because the parameters of these levels are relatively simple, I recommend you make the editor a part of the compiled application, not part of the Unity editor. In ...


0

State Management is what you're looking at. It's an entire idea of how to manage the current state of your game, and is often seen like a large state machine. It all falls under the Model View Controller design pattern. However implementing it is where things get interesting. You've already mention XML, so why not JSON? It's got native support in Unity, and ...


3

The version by Byte56 works if the mesh is on the prefab or one of its first level child-objects. When it's deeper in the object hierarchy of the prefab, you can't expand it in the project tree. In that case: Drag prefab into scene Change the mesh in the MeshFilter component of the sub-object Click on the main object of the prefab Click "Apply" in the ...


1

Modifying the velocity will interfere with your physics if you're not sure of what you're doing. Ideally, you'd move things around by adding forces. Using Rigidbody2D.AddForce is the least complicated way to move objects that have a RigidBody.


6

Import the mesh into Unity Select the prefab you want to modify in the Project Window In the Inspector, select your new mesh from the Mesh Filter component This will update the prefab and any instances you have in any scenes.


1

Well, I found something interesting...Editor window designer The plugin is almost what I need The project had been started but not completed yet. As the author says: he decided to release Editor Window Designer as an open source project, that code is here For now plugin allows add elements and styling them (position, padding, width, height, e.t.c) Base ...


2

When you are using the Unity physics system, the engine offers you a WheelCollider which handles wheel physics for you. Usual practice is that the wheel colliders are not attached to the wheel mesh but rather to the vehicle body directly. So they are supposed to simulate "invisible" wheels. You then control the vehicle by changing the motorTorque, ...


2

The idea is that you need to have the outer part of the wheel go on the ground at the same speed that the one of the vehicle. Assuming you have these values beforehand: vehicle_speed // in meters per second wheel_radius // in meters You can infer this one: wheel_circumference = 2 * PI * wheel_radius // still in meters You can then get the rotation ...


1

I think you have created many jar files. Combine the two or more jar files into one and give them the same package name. If you get the jar file from Eclipse, create more classes in the same package, and call this package name into your plugin. This will be a better choice.


1

It turns out I should have paid more attention in CS class. I didn't realize Unity overrides any initialized values from scripts with whatever is present in the Inspector. Having made all my variables public, the Inspector was overriding them every time, even when I used [HideInInspector]. Simply making all the variables private (which they should have been ...


1

(Sorry for poor formatting - I'm on my phone) There are a lot of valid options. If I were tasked with this, I would probably do one of two things: Save the level data in Google Sheets and use one of the google sheets assets available on the asset store to pull it into the game either at design time or run time. Or: Save the level data in ...


3

First of all if you are interested in generating meshes I recommend to you this series of articles in gamasutra about procedural meshes Modelling by numbers So returning to the main question, generate planes procedurally allows you to define the distribution of the vertex, for example I use this kind of methods to generate low poly terrains So if you ...


0

No, since the scripts are compiled (before run) and therefore can't be manipulated at runtime. However: you could add debug fields to your scripts to change certain fields (let's say a color or so).


0

You may want to consider setting up your transitions based on a time period instead of a multiplier. That way, you can instead adjust the "Duration" of your transition in milliseconds instead of fiddling with multiplier values. Consider something like this: float Duration = 0.5f; const float DURATION = 0.5f; Vector3 StartSize = Vector3.one; Vector3 ...


0

There is no conventional approach in designing a game really. You do whatever works for you. You can have full physics in your game, or you can fake it all. Back to your question though, since the levels of a game like this are all random and also proceduraly generated, then just use one scene with a camera only. Switch from main menu to game type ...


0

You could always use LeanPool. Its a free asset on the asset store. It does object pooling for you. Then you can do a simple cull system around the cameras view that spawns/de spawns tile gameobjects as they enter/exit the cameras view. Im not sure on how big your tilemap is going to be but Unity can handle quite a bit of gameobjects. LeanPool has benchmark ...


1

I would recommend you to place the 2d sprite not in the game world but instead place it on a UI canvas with "Screen Space - Overlay" mode. You can convert the game-world position of a GameObject to screen-coordinates using Camera.WorldToScreenPoint. Then you need to convert the screen coordinates to canvas coordinates and place your sprite there. Code ...


2

If the slider is skipping over the value you need, why can't you just enter it in the value box?? It looks like you can also hold ALT down, which will give you some more granularity when using the slider


0

Check if button is held down by user. create a bool value and turn it true if the button is held down and false if not. then move the player is bool value is true and stop if false.


-1

Try \n. What you can do is create a UI text and write in that, remember you have to still put \n to skip to new line.


0

Is your player's rotation always controlled by animation, and is there a rigidbody attached to the child object? If so, this would explain the discrepancy you are seeing. The values you see in the inspector will be after the animations are applied, while the values you get during Update will be from before. Do you get different values in your replay ...


0

I am not aware of an easy way of doing this. The way I'd do this is the following: Determine XY position of click on texture (x = 0..1, y = 0..1) How to do this depends on where you use it, but will likely require raycasting. Go to the camera that sends the image to the texture. Assuming the camera uses perspective projection: Calculate the 3D ...


1

You need to activate the Collision under particle system component itself and set the Collision to be 'World' for particle system component and also check the 'Send Collision Message' check box under Collision. Refer this url http://answers.unity3d.com/questions/715622/world-particle-system-collider-what-am-i-missing.html


-1

The problem is solved using OnMouseDown() method. Attach this script on the object oon which you want to trigger click event. Don't forget to add collider on that object. public class MouseDownEffect : MonoBehaviour { [SerializeField] private GameObject TempCharacter; void OnMouseDown() { StartCoroutine (IncreaseScale ()); } IEnumerator ...


1

In the particle system component properties you can find a tab that is called collision, then you just tick it and set it to world space, and in order to be detectable you could add a tag to the particle system and make other objects check for the collision with the objects with that tag.


0

What is happening is that your "nextPoint" vector is not actually describing a point in world space; it is describing a direction and distance away from your starting point. So in order to get the world space position of where this vector is pointing to, take the world space position of your starting point, then add your offset vector to it: nextPoint = ...


0

You could add a child to the barrel and add a script to the child that will set one of its rotation axis to the starting value which means one of its rotation axis eg. forward will always stay the same and it could act as an indicator of the forward direction of the barrel since it will be moving and rotating on other two axis the same as the barrel. Your ...


0

What you can do from the OnDrag implementation of the button is this. public void OnDrag(PointerEventData eventData) { if(scroll)// scroll is the GameObject with the ScrollRect component you will have to ckeck for the different drags here. { scroll.SendMessage("OnDrag", eventData);//This passes the drag message that started ...


5

Locking at 60 fps is certainly viable. From what I've seen, just as you've said, it appears fighting games typically describe timings in number of frames, even as most fighting games have transitioned to 3D (where it's rare to rely on discrete frames of animation). The drawback of doing this logic in Update() in Unity is that the game will slow down if the ...


0

Instead of checking how many frames have passed, try checking how much time has passed instead. In Unity, you can check how long the previous frame took to complete with Time.deltaTime. Delta time for 60 frames per second is 0.016666 (6 continuing). So, add delta time to a float variable every frame, then check if it is greater than X (where X would be about ...


-2

You can use a coroutines for this task, you should call this coroutine in order to damage you player, so you can set a time of invencibility with the waitForSeconds(3f); function bool finishedCoroutine = true; void OnTriggerEnter2D (Collider2D other) { if (other.gameObject.tag == ("Damage")) { { if(finishedCoroutine){ ...


0

For stylish control: Define this 50-length array A of numbers: 1,0.9,0.8,0.7,0.6,0.5,0.4,0.3,0.2,0.1,0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 These are alpha values for 1/2 second, which is the repeat sequence for the 9 s blinking part of your question (0.1 + 0.1 + 0.3 s). These 9 seconds hold 18 ...



Top 50 recent answers are included