Hot answers tagged

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


3

According to the Unity documentation for OnTriggerEnter2D the trigger is "[s]ent when another object enters a trigger collider attached to this object (2D physics only)". The function should only be called once per entrance. You could gather further data by logging the number of calls to OnTriggerEnter2D and OnTriggerExit2D. Perhaps some funny business is ...


3

Unity remote sends a compressed stream from the editor to your phone and then sends back the inputs from the phone to the editor. there is nothing you can do about it being bad quality. How ever this does not represent the final quality of the build. Try making a real build for android and check how it looks then.


3

When you write transform without anything in front of it, it refers to this.transform, ie. the transform attached to the GameObject this script instance is running on. It sounds like you instead want to modify the transform of the object hit by the raycast. To do this, we need to capture a reference to it... Ray ray = new Ray(transform.position, ...


3

Assuming that you're making a 3D game, you can use Physics.OverlapSphere to get a an array of Colliders that are within a certain range of the player. To check if the object is "visible" to the player, you could simply call Physics.Raycast in the direction of the object(s) returned by OverlapSphere and check if nothing that isn't the object you're checking ...


2

void OnTriggerEnter (Collider obj){ if(obj.GameObject.GetComponent<motor>().enabled == true){ passed = true; } } adding this GameObject --> obj.GameObject.GetComponent().enabled would just work :) let me know if it works


2

I was able to eliminate all of the GpuProgram warnings and also fix all of my animations by trial and error elimination of several shaders and additionally re-importing the models from Blender. Steps as follows. I set all of the models to use the standard shader in Unity. I then deleted and reloaded the offending shaders and did not have any errors, this ...


2

This can be done with a very small modification to the script in the question Philipp linked: public class BlendFollower : MonoBehaviour { public Transform leader; public float followSharpness = 0.1f; Vector3 _followOffset; void Start() { // Cache the initial offset at time of load/spawn: _followOffset = ...


2

This is a strange behaviour in Unity's scale inheritance system. If the parent has a non-uniform scale, when you rotate the child, they deform/stretch like a rubber band. Try adding an empty child GameObject to Player GameObject and parent the Camera GameObject to empty one, and put the rotation script on Camera. This makes parent of the Camera a ...


2

The method you are looking for is Quaternion.LookRotation. First you need to calculate the relative vector between player and tank. You do that by simply subtracting the position of the tank from the position of the player. Then you use Quaternion.LookRotatation to create a rotation into that direction. Vector3 playerDirection = player.transform.position - ...


2

If you want to prevent cheating then the client could be treated as a dummy terminal displaying state and accepting input. The problem with this is that you have offloaded ALL of the work to your server. As the number of people increases on the server so to will the computational load. Correcting this problem can be solved in a number of ways such as ...


2

Are you trying to use CompareTag on the gameObject that your RaycastHit is returning? If so it looks like you would need to do "hit.collider.gameObject.CompareTag". Or if that doesn't work, you would need to move that condition into a nested if statement. So: if (Input.GetMouseButton(0) && Physics.Raycast(ray, out hit, 10f) && ...


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


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


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

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.


1

You can merge the meshes of multiple game objects into one using Mesh.CombineMeshes. Note that this does not care about which materials you assigned to the input meshes. The GameObject into which you merge the meshes will use whatever materials you assign to its own MeshRenderer. That means when you are merging meshes with different materials, you should ...


1

Disclaimer - I'm not a unity dev & as such I'm not familiar with all its options, but it does look like it has support for merging meshes together to increase performance. In general how to tackle this problem will come down to tensions between player freedom, code performance, & development resources: The more you constrain player choice, the ...


1

I can't understand your question but refer this URL to Create more then animation to one gameobject https://www.youtube.com/watch?v=O_0gZuqW6y8 https://www.youtube.com/watch?v=giSjcA109CE https://www.youtube.com/watch?v=MtJhZ4pJXlM


1

Rigidbody Contraints is a class to use for the rigidbody. In your case, instead of using hit.transform. = RigidbodyConstraints.FreezeRotation;, I would replace that with hit.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezeRotation;I see that you have tried to set a Rigidbody class on a Transform. Rigidbody constraints take a ...


1

As mentioned in the comments you probably want a Raycast. An example of how to implement a forward-facing raycast in a Fixed Update cycle is spelled out exactly in the Unity Scripting API Documentation here. This will return true if the raycast strikes a collider in front of whatever object you attach the script to. From the documentation above: using ...


1

You can use the dot product trick to get a list of instances actually visible by the player (thus lying inside the camera frustum), and check for the distance from your camera object to get the closest one. First, you can test a certain number of instances so that their distance is low enough for them to be considered "near" the camera (or the player). ...


1

I would advise using neither for this particular case. InvokeRepeating takes a method name, which means it's using reflection at runtime to look up the method to call. That's work we don't need to do, since we can already point the compiler at the exact method we want. Update executes every frame, but for spawning we typically want to leave some time (or ...


1

I dont think you can turn off the vibration feature of the device. Your game will not vibrate the device unless you call Handheld.Vibrate(), so in your Toggle function why not just set a bool to true or false and do a check against that bool when you want to vibrate. You can actually implement a Toggle control from UnityEngine.UI and use its OnValueChanged ...


1

Animator.Play() works with the state in the Animator not the actual animation. I'm guessing you are not returning from the Flip-Forward state. Make sure to create a transition from to that state back to the default state and that the transition Has Exit Time property be ticked. This is a simple example of how the state machine should look. However I ...


1

use a mesh collider instead ! i just had the same problem. but then i just used a mesh collider instead of a sphere collider and the problem almost solved itself just be sure to update the mesh collider shared mesh as well: var meshInstance = Instantiate(meshes[type]); gameObject.GetComponent<MeshFilter> ().mesh = meshInstance; ...



Only top voted, non community-wiki answers of a minimum length are eligible