_id
int64
0
49
text
stringlengths
71
4.19k
0
How is entering cover animation done for cover system? I am trying to create a cover system for my 3rd person shooter game in Unity. My implementation is a basic one On Player enter Trigger Player move to preset cover position Player play Enter Cover animation (eg dash to cover) This is fine without root motion enabled, when it is enabled (so the movements look natural), instead of dash amp stop behind the cover, the Player will dash and stuck himself inside the cover (due to root motion). So I am curious, what is a good way to do the animation for cover system?
0
Mesh does not translate accordingly to WheelCollider So I am trying to implement a car controller script in Unity were the WheelTransform position and rotation is set with every update as the same as the WheelCollider position and rotation, it all works fine except for one thing when translating the WheelTransform, if the car goes slowly, WheelTransform translates as expected, but when the car goes faster, there's a clear offset between the WheelTransform position and the actual position of WheelCollider. Here's the code were WheelTransform position and rotation is set as the same as the WheelCollider position and rotation private void UpdateWheels() UpdateWheelPos(frontLeftWheelCollider, frontLeftWheelTransform) UpdateWheelPos(frontRightWheelCollider, frontRightWheelTransform) UpdateWheelPos(rearLeftWheelCollider, rearLeftWheelTransform) UpdateWheelPos(rearRightWheelCollider, rearRightWheelTransform) private void UpdateWheelPos(WheelCollider wheelCollider, Transform trans) Vector3 pos Quaternion rot wheelCollider.GetWorldPose(out pos, out rot) trans.rotation rot trans.position pos Every single one of the car controller scripts I've found and tried use the same code for this section, I have also tried with 2d sprites without any colliders as WheelTransform but neither the scripts or changing WheelTransform solved the problem. Thanks in advance for the help.
0
How to move a cube withour rolling it? I am trying to move a cube with my keyboard on a plane surface. However, the cube always rolling instead of moving. How could I slide the cube on the plane? What I have done I added a plane game object with a mesh colider I added a 3D cube object with a box colider and rigidbody I appended a ControllerScript to the cube ControllerScript private const float Speed 10 private Rigidbody rb void Start() this.rb GetComponent lt Rigidbody gt () void FixedUpdate() var x Input.GetAxis("Horizontal") var z Input.GetAxis("Vertical") this.rb.AddForce(Speed x, 0, Speed z) It looks like the AddForce method upset the cube. I already tried to reduce the friction of the plane and the cube, but this only delays the problem. How could I move the cube without rolling it? Whats the common way to do it?
0
Touch input not working well for mobile game made with Unity 2D I made a simple game in unity where the user taps their phone screen and the player jumps up. When I test it on my phone (not sure if this matters but it's a Samsung s9 ), I tap the screen and usually the tap causes the player to jump up and fall back to the platform properly, but sometimes when I tap the screen nothing happens at all it just stays in place. The game on my phones is also very slightly laggy (although, on my computer it runs smoothly) and I'm not sure how to fix that either or if they're related. This is the code attached to the player void FixedUpdate() Jump() Dead() void Jump() if (Input.touchCount gt 0 amp amp isGrounded) gameObject.GetComponent lt Rigidbody2D gt ().AddForce(new Vector2(0f, jumpForce Time.fixedDeltaTime), ForceMode2D.Impulse) Also, I know that it's the touch input that's the problem, because when I make it so that pressing the up arrow key on the keyboard makes the player jump, it works perfectly fine. If there's some other information about the game you'd need to know to answer my question, let me know. Thanks for your help.
0
Make a flying object rotate so the camera sees the rotation When I attach a camera to my flying object (plane), when I rotate the object, the camera is perfectly following it so you can't really "feel" the plane rotating. I want to create the effect that you see in flying games where you see the plane rotating along the x axis (so you see the nose go up and tail down) while also semi following the plane, creating a better effect. How do I achieve this?
0
Attach movement to each list object How would i move every sphere that gets spawned every 2 seconds ? Basically i want every sphere to follow the previous spawned sphere or even all N 1 spheres should follow the first spawned sphere along a predefined path and they should keep rolling as a train of spheres. I am lost when i try to imprint movement to each sphere. using System.Collections using System.Collections.Generic using UnityEngine public class Spawner MonoBehaviour public GameObject prefabs public List lt GameObject gt listBalls new List lt GameObject gt () private GameObject x public int timer 0 private float movementSpeed 5f void Start() createBall() void Update() if (Time.time timer gt 0.8f) createBall() timer 2 listBalls listBalls.Count 1 .transform.position new Vector3(0, 0, movementSpeed Time.deltaTime) void createBall() x prefabs Random.Range(0, prefabs.Length) Instantiate(x, x.transform.position, Quaternion.identity) listBalls.Add(x) void moveBall(GameObject x, GameObject y) x.transform.position y.transform.position new Vector3(0,0, 1) Loop added but movement staggered void Update() if (Time.time timer gt 0.8f) createBall() timer 2 foreach (GameObject item in listBalls) item.transform.position new Vector3(0, 0, movementSpeed Time.deltaTime)
0
Player animating the wrong direction once he is rotated I have used the scripting root motion move the player when using an 'inplace' animation. All works correctly until the players rotation is off 0,0,0. This is expected as the movement is along the transform.z axis but how can I account for the rotation in the script and apply it so the movement is correct in game? The gorillacontroller script is the script we are trying to fix On playerGorilla. animator is on the playergorilla. The gorilla1 is the gameobject holding the mesh and the bones for the character. I will also add the transforms are moving this was my silly mistake because I had tool handles in global instead of local. This makes it even more confusing however because all tranform.z (blue axis) are facing the correct way for the animation to work but the animation is only ever playing in the original direction where the rotation is 0,0,0,0. using UnityEngine using System.Collections RequireComponent(typeof(Animator)) public class RootMotionScript MonoBehaviour void OnAnimatorMove() Animator animator GetComponent lt Animator gt () if (animator) Vector3 newPosition transform.position newPosition.z animator.GetFloat("Runspeed") Time.deltaTime transform.position newPosition
0
Frame Dependency vs Time Dependency Just today, I was dealing with this very topic in class, and I had a hard time following through the lectures. Could someone explain to me what it means for something to be frame dependent, in layman's terms? As far as I know, it's not Unity specific. I suppose this applies to every game, regardless of its engine. An elaborate answer would do really good for me, as I'm a student, and I'm gonna be doing projects on this. Thanks!
0
A Pathfiding movement is not stopping and constant I'm trying to make my player move towards mouse click using A Pathfinding but I'm having some odd issues that I can't solve. One of the issues is that player is moving a little bit even though it arrives at the position of the other transform The second one is that the force is that is applied to the player is not constant, I would like it to keep always the same movement speed. I've tried to change to use transform.Translate to move the player with constant movement speed but it makes the movement to be like walk a little then stop, walk a little then stop... This is the code that I'm using using System using System.Collections using System.Collections.Generic using Pathfinding using UnityEngine using UnityEngine.UI public class Player MonoBehaviour SerializeField private float speed 100 SerializeField private Text lifeText SerializeField private int life SerializeField private GameObject target SerializeField private float nextWaypointDistance 3f AI configurations private Path path private Rigidbody2D rigidbody private Seeker seeker private int currentWaypoint 0 private bool reachedEndOfPath false Start is called before the first frame update void Start() seeker GetComponent lt Seeker gt () rigidbody GetComponent lt Rigidbody2D gt () InvokeRepeating( quot UpdatePath quot , 0f, .2f) Update is called once per frame void Update() lifeText.text quot Vida quot life.ToString() if (Input.GetMouseButtonDown(1)) right click Vector2 mousePos Input.mousePosition Vector2 worldPos Camera.main.ScreenToWorldPoint(mousePos) target.transform.position worldPos private void UpdatePath() if (seeker.IsDone()) seeker.StartPath(rigidbody.position, target.transform.position, OnPathComplete) void FixedUpdate() if (path null) return if (currentWaypoint gt path.vectorPath.Count) reachedEndOfPath true return else reachedEndOfPath false Vector3 direction (path.vectorPath currentWaypoint (Vector3)rigidbody.position).normalized Vector3 force direction speed Time.deltaTime rigidbody.AddForce(force) float distance Vector2.Distance(rigidbody.position, path.vectorPath currentWaypoint ) if (distance lt nextWaypointDistance) currentWaypoint private void OnPathComplete(Path p) if (!p.error) path p currentWaypoint 0 What I want to is to make the movement smoother and with constant movement speed. Can you guys help me?
0
Convert coroutine into void I want to get rid of a co routine and do this with a void. How could I convert his IEnumerator into a void? private IEnumerator pChangeFoV() float zValue 70f for (float t 0f t lt FoVDuration t Time.deltaTime) float fNew Mathf.Lerp( camera.fieldOfView, zValue, t FoVDuration) camera.fieldOfView fNew yield return 0 camera.fieldOfView zValue Thank you for the help!
0
How to import Blender mesh rig separately from animations for generic rigs in Unity? Currently I'm creating mesh, rig and animations in Blender and export them together as an fbx file. I know that importing animations separately works for humanoid meshes, but how to do this for a generic rig? Why? After importing a character, I have to add components to some bone game objects of the characters rig. Adding or changing animations of an already existing character currently requires me to reimport mesh rig aswell as the animations and then add the components to those game objects again. Also sometimes the reference of existing prefabs to the reimported mesh is lost and I have to add the mesh to those prefabs again, this might have been me doing somethin wrong though. Better solution? I also thought about naming bones in blender in a certain way and have a script in Unity add these components, I would still prefer to import animations separately though. Thank you in advance!
0
Can I integrate Unity 5 with the 0.6.0 runtime for Oculus DK2? I am a new user and I am trying to get the Oculus running on an old PC. I had a few issues with the latest SDK so I am currently using the 0.6.0.1 beta version. I would like to integrate Oculus with Unity. My question is whether I can use Unity 5 with the SDK 0.6.0.1 beta and which kind of integration should I use or if I should download a previous release of Unity. Thank you!
0
Instantiation of multiple objects with varying velocities I am looking to multiple objects of the same prefab at the same time with varying velocities. public GameObject prefab public float xDirection public float yDirection void Update () GameObject prefab1 Instantiate (prefab,transform.position,quaternarion.identity) as GameObject GetComponent lt RigidBody2D gt ().velocity new Vector2 (xDirection,yDirection) I want to create three instances at once, but have the x y direction be different. I am looking at creating an instance at three separate velocities. I know I can do something like this using void Update () if (Input.GetKey(KeyCode.space)) xDirection 1f yDirection 1f shootObject() xDirection 2f yDirection 2f shootObject() xDirection 2f yDirection 2f shootObject() void shootObject () GameObject prefab1 Instantiate (prefab,transform.position,quaternarion.identity) as GameObject GetComponent lt RigidBody2D gt ().velocity new Vector2 (xDirection,yDirection) but I feel like there is something else that I should be able to do to simplify this even further since this seems to be very messy code. (I apologize if something seems a little odd. Have only been coding for around a few weeks.) Thank you for the help!
0
Unity raycast equivalent in Unreal I've been moving from Unity to Unreal and I'm finding it difficult to grasp the Raycast (Trace) logic of Unreal. The use case I'm trying to implement at the moment is to trace a ray and check if I hit a specific set of objects or if there are other objects blocking the line of sight. In Unity, I would use Raycast, define a new specific Layer, set the object layer to it, create a LayerMask with that Layer and Raycast. I consider this method to be performant as the use of layer masks provide a form of optimization and most importantly I'm guaranteed that if the ray hits an object than it's because its layer is part of the layer mask and if I'm using multiple layers I could simply check which layer the hit object has. In Unreal it's been harder to understand what are the solutions that offer better performance and are easier to use. The C documentation for Line Trace (channel or object type) is very poor when comparing to Unity's. Can anyone shed some light on how to move from the Unity logic to Unreal using the above use case as an example?
0
My script isn't deleting or destroying my prefab game object in Unity2D My script isn't deleting this game object once it reaches a certain position in my game. This is my script public float left public GameObject enemyLeft void Start () enemyLeft GameObject.Find("Enemy Left") void Update() if (transform.position.x lt left) Destroy (enemyLeft) enemyLeft is a prefab gameObject that is being spawned in by my spawner. This is the script where I intend to Destroy the game object public float left public GameObject enemiesLeft void Update() for (int i 0 i lt enemiesLeft.Length i ) if (enemiesLeft i .transform.position.x lt left) Destroy (enemiesLeft i ) Why isn't it deleting the game object?
0
Why is Unity3D on OSX ignoring my XBox 360 controller? I'm using a fork of the Tattie Bogle driver that has a signed kext. The System Settings panel shows all inputs correctly. One axis is configured in Unity3D 5 like this Still, I don't see any input when the game is running. I also cannot configure Positive Negative Buttons for any input in the Input Manager panel clicking the input line edit and entering a keyboard key works fine, but pressing a controller button does nothing. What am I missing here?
0
How to make player instantly move to the right or left when entering a box collider I have a box collider and right now when I walk into it it says "you can't go there yet" I would like it for it to also move the player like 3 steps to the right or something. How would I do thatr?
0
Unity3d mesh is getting distorted while animation I attached boxing glove to rig using this method https stackoverflow.com questions 34719718 transferring rig weights from one mesh to another in blender 2 76 It works fine in the blender, But while animating in unity mesh is getting distorted. Image https imgur.com a 5McCX Anyone knows how to fix this?
0
Unity3d iOS unable to find iPhone GlesSupport.h i've an old unity project and i've tried it just today (with unity 4.1) and xcode 4.6. Xcode is unable to build it for the error "iPhone GlesSupport.h" file not found. Im pretty a noob under xcode and objective c in general so i've searched in internet about this problem, but without any luck. Anyone know more or have experienced this problem? Thanks
0
Declaring Keycodes as strings How do I declare the keycodes as strings instead of selecting the keys from a list? Such that the user can input a key in inspector window and it will be read? public string StringKey quot a quot void Update () if (Input.GetKeyDown (KeyCode.StringKey))
0
Hold and swipe can't work together I Have a character in my game that must go when player hold finger at the screen, but when I swipe character first go, and then do swipe. (for example jumping character first go, and only then jump). This my code for touch if (Input.touchCount gt 0) Touch touch Input.GetTouch(0) if (touch.phase TouchPhase.Began) startTime Time.time startPos touch.position else if (touch.phase TouchPhase.Ended) endTime Time.time endPos touch.position swipeDist (endPos startPos).magnitude swipeTime endTime startTime if (swipeTime lt maxTime amp amp swipeDist gt minSwipeDist) swipe() else if (touch.phase TouchPhase.Stationary amp amp isTap 0) hold() This my code for a hold void hold() moveVelocity 3f And for swipe void swipe() Vector2 distance endPos startPos if (Mathf.Abs(distance.x) gt Mathf.Abs(distance.y)) if (distance.x gt 0) Debug.Log("Right swipe") if (distance.x lt 0) Debug.Log("Left swipe") if (Mathf.Abs(distance.x) lt Mathf.Abs(distance.y)) if (distance.y gt 0) Debug.Log("Up swipe") if (distance.y lt 0) Debug.Log("Down swipe") My question is When player swipe left character first go, and only then do swipe left. I want player swipe, without going forward. How can I do this?
0
Animation doesn't play in one state I have created an Animator and two sprite based Animations. Both Animations preview correctly. In the Animator, I have created two states and two transitions between them based on a Boolean parameter. In the GameObject's script, the Boolean value is set based on distance to the player. When the player is far away Animation A plays and when the player is close Animation B plays. However, while the transition from Animation A to B happens correctly when the player gets close, I only see the first frame of Animation B and it doesn't animate. If while in Play mode I preview Animation B (using the Animation window controls), it animates correctly. Meanwhile, Animation A always plays correctly when it is supposed to. What could cause this behavior? How can I get Animation B to play during runtime and not just when previewing? What's going on? Edit Some screenshots. quot Saw slow quot is quot Animation A quot above, and quot Saw fast quot is quot Animation B quot . Animator Animator State Slow Animator State Fast Transition slow to fast Transition fast to slow Animation Slow Animation Fast The code is very simple bool trigger playerDistanceSqr lt (activeDistance activeDistance) animator.SetBool( quot IsFast quot , trigger)
0
Keep a rigidbody velocity constant I have a "board" with a ball (rigidbody) moving over it and colliding with obstacles. I want its velocity magnitude to remain constant throughout time. How do I achieve this? What I've tried achieved so far My first guess was to use OnCollisionExit to set the velocity manually, but that lead to weird physics. I don't see how to use AddForce to do this since the previous movement would still be factored. To be clear, what i want is to set the velocity at all times to rigidbody.velocity.normalized x magnitude, where magnitude is a float I set previously. This would allow the physics engine to make all impact math to decide the direction of the ball after the collision, but my math would keep the velocity intact. I then decided to add UpdatedFixed and on every call set the velocity as stated above. It's working, but feels like a bad hack because I'm updating the velocity every frame and forsaking the physics engine.
0
How do I rotate the Camera around the player by Keypress in Unity? I want to rotate the camera around the player by pressing E and Q but it doesnt rotates around the player. I tried RotateAround but didnt worked. Code public Transform player public float smoothSpeed 0.125f public float rotateSpeed public Vector3 offset private Vector3 velocity Vector3.zero void LateUpdate () transform.position Vector3.SmoothDamp(transform.position, player.position offset, ref velocity, smoothSpeed Time.deltaTime) void Update() if(Input.GetKey (KeyCode.E)) transform.RotateAround(player.position, Vector3.up, rotateSpeed Time.deltaTime) if(Input.GetKey (KeyCode.Q)) transform.RotateAround(player.position, Vector3.up, rotateSpeed Time.deltaTime)
0
Bounce ball after collision I added Box Collisions (Walls) outside of the screen and a player (ball) with rigidbody and Circle Collider in dynamic forcing to a random direction. I want the ball to bounce when it collides the wall. Bomb.cs private Rigidbody2D rigidbody private Vector2 direction Use this for initialization void Start () rigidbody gameObject.GetComponent lt Rigidbody2D gt () direction new Vector2 (Random.value, Random.value) Update is called once per frame void FixedUpdate () rigidbody.AddForce (direction)
0
Getting world space vertex coordinates in Unity I'd like to get world space coordinates for a specific mesh vertex. Transform.TransformPoint() seems to be what I need however I'm unable to get the correct position. In the scene I have an object called "head" at Pos (0, 0, 0) Scale (0.03, 0.03, 0.03) and I'm trying to get the position of vertex id 590 in order to spawn another object at that specific location. Mesh mesh GameObject.Find ("head").GetComponent lt MeshFilter gt ().mesh Vector3 vertices mesh.vertices Vector3 newPos transform.TransformPoint (vertices 590 ) Debug.Log (newPos) The value of newPos is not on the head object.
0
Why does Unity require an EventSystem component for input during a play test, where input works fine without it in a build? Please be aware that this was initially a question about how to get the input to work. A comment pointed me in the direction of a fix, but only left me with more questions in regards to understanding the problem I was originally having, so I have edited my question to include the initial solution and focus on the question I still have. The Problem Recently, I have moved from using GUIText and GUITexture objects to using the Canvas to display UI elements. In effort to set up a prototype, some external GUI elements were imported, and when the game is built and run from my phone, everything works as intended. However, if I simply run the game from inside Unity, input is completely ignored. I originally thought this may have been a response to grabbing touch screen input, and expecting it to work on a regular screen with mouse input, but I have since confirmed that it still does not work when using Unity Remote to test the game on my phone. It has since been pointed out that I was not using an EventSystem, along side my Event Trigger objects. After implementing an EventSystem component, and the default input module supplied by the EventSystem interface, the input works. However, this still leaves me confused. What is the point of enforcing the implementation of the EventSystem, if it only ensures functionality during play test? Why would I want this system in my end build, when I can confirm that the build version functions properly, without it? Below you will find my setup, contextual to the problem. Click for a zoomed in view, as I have included the component structure of my UICanvas and MainCamera objects, in case it is helpful. In this case, we have a button that increases the max speed, when pressed. Everything works in a build, but nothing works during a play test. Additional Information I have enabled 'show touch input' on my phone, to confirm that the phone is still registering touch input. I moved to using the Canvas object after the 'depreciated warning' for using GUIText and GUITexture turned into a 'depreciated error'. Even if there is a suitable way to still perform these actions with the GUIText and GUITexture objects, I still wish to persist with using the Canvas. I am also personally curious as to why this issue exists within the Canvas, as it seems lead to obvious cases of severe inefficiency, in a system that seems to have been put together with the sole point of being more efficient. I can create manual OnMouseDown buttons that will work during play test, however, some GUI elements are more complex and persisting with this sort of solution seems like an incredible waste of time. As previously mentioned, I do not have any input issues if I simply build and run the game from my phone. However, this takes considerably more time than a simply debug test, and even without the high efficiency cost, I do not have access inspector manipulation during my play test. I am using Unity version 5.3.5 personal. Any solution that does not include updating Unity will be well preferred. While I have no physical problems updating Unity, in some previous projects updating Unity versions has lead to massive issues that we would prefer to outright avoid, if possible. TL DR Unity will not accept input on my input canvas during debug. I literally have to build and run my project each time I want to test input, or create dodgy hacks to provide input from the Inspector. The addition of an EventSystem allows input during debug play testing, but is not needed for input post build. Why does Unity act this way, and why do I need an EventSystem entirely for play test input?
0
Outputting Unity commandline build log to console? I'm using Blue Ocean to do a Unity3D build through command lines (https docs.unity3d.com Manual CommandLineArguments.html). I currently have a stage in blue ocean which runs the build command in a 'Windows Batch Script' outputting the log to a text file on the computer. is there a way to also output that same logging text to the blue ocean build output? Right now all I see is the batch command. One way to accomplish this would be if the build output was sent to the console instead of just the logfile passed in the argument.
0
Is there a way to check android version running the game using Unity3D? I want to separate code to run only on android 4.4 or higher. If it's lower, I do not want to run this code. What should I do?
0
Hide back button bar of android mobile while playing game I just want to hide back button bar of android mobile while playing the game. I tried to make it close by pressing back button,it getting close but its always visible. please help..
0
Kinect for Xbox One ( adapter) and Windows 10 Can I use Kinect Xbox One (with adapter like Kinect for Windows V2 device), SDK 2.0, to build applications on Windows 10? I've read the requirements for Kinect and it lists only Win 8.0 and Win 8.1. I'd like to use Kinect Xbox One device with Unity 3D and Hololens. Before I buy the device I'd appreciate if anyone can share some experiance or at least to confirm that would be possible to develop apps with Kinect for Xbox One on Win10? Many thanks.
0
In Unity, how do I move my character to an object when I click on it? Basic question here, and I feel like I'm close but can't quite get it. I have an object it's a pot on a stove that is in my 2D game. There will be multiple pots that appear and disappear in the game, all in predefined places (like on top of the burners of a stovetop). There's also a chef in the game, who goes to each pot and does an action. The user never directly controls the chef's movement instead, when the user clicks a pot, the chef runs over to the counter in front of that pot, where he can perform an action on the pot. Can someone tell me how to do this? I'm not only looking for the code but for a "correct" design, in terms of where the various variables and methods should be located. In other words, what goes in the pot's script and what goes in the chef's script? (I'm using C .) My thought was that the pot GameObject would have an OnMouseDown() method, to catch the user clicking on it. And in that method, there should be a call to a Move() method that is attached to the chef GameObject. But what I have is not quite working. The chef moves one small bit toward the pot but then stops. I realize that this is because I'm calling the Move function once and that's it it seems like the Update method should be involved somehow (the pot's or the chef's?) or maybe I should have an if statement in my Move method that checks to see if the user is at the pot, and if not, runs the move code in a loop. Or maybe the design is just fundamentally wrong and it could be done more easily. Here is the code I have public class PotController MonoBehaviour private GameObject chefObject void Start () chefObject GameObject.Find ("Chef") void OnMouseDown() ChefController chefScript chefObject.GetComponent lt ChefController gt () chefScript.Move () public class ChefController MonoBehaviour public float moveSpeed private Vector3 moveDirection public void Move () Vector3 currentPosition transform.position if (Input.GetButton ("Fire1")) Vector3 moveToward Camera.main.ScreenToWorldPoint (Input.mousePosition) moveDirection moveToward currentPosition moveDirection.z 0 moveDirection.Normalize () Vector3 target moveDirection moveSpeed currentPosition transform.position Vector3.Lerp( currentPosition, target, Time.deltaTime )
0
How to create a forest game scene in unity3d? I am pretty new to game development. I have started using unity3d. I have created simple games for which I have used plane (3d gameObject). Now, I want to move a step forward I want to create a forest with mountain and trees. So, I went through few tutorials and concluded terrain (3d Object) will be best fit. Issue My player falls down from the terrain due to gravity and if i disable gravity then my player flies up in y axes when moved over mountains. What is the way i can create terrain with gravity and so that my player doesn't fall from the terrain. Can anyone throw light on how do overcome above mentioned issue.
0
How should I deal with different enemy types? I'm making simple space shooter game for Android in Unity. I want to have different types of enemies (different weapon, stats, movement schemes) and I'm not sure how to do it. I'm quite new to objective programming and I don't really know what classes should I create. I guess I could just make a prefab for every enemy since there won't be many types, but that is not what I'm looking for. I have some ideas First of all I'd write an BaseEnemy class and enemy type subclasses that inherit from it. My first idea is to create those without MonoBehaviour. Then I'd have to make an EnemyScript with MonoBehaviour that I'd add to enemy game object. It'd have a specific subclass object inside, which will set every variable. BaseEnemy would just have undeclared variables and in subclass I'd set particular values. But I'm not sure how to deal with different movement schemes then. I wouldn't be able to put move() function in subclass since it wouldn't have MonoBehaviour, so I'd have to find another way. I might put in EnemyScript every possible scheme and then use correct one depending on some type value, but it doesn't seem like a proper way, does it? The second idea is to just make a MonoBehaviour BaseEnemy class. Then while creating enemy game object I'd just add correct subclass script (aaand... I'm not sure how to do it ) Could you tell me which one is a better way? Maybe neither of those?
0
Initializing Variables, Difference between Awake and in class initialization public class ExampleClass MonoBehaviour int exampleVariable 0 int exampleVariableForAwake void Awake() exampleVariableForAwake 0 What is the difference between initializing a variable at declaration vs. initilize in Awake? Which I understand is to be used in place of constructors in Unity C , welcome to correct me if I'm wrong. Which usage is considered a proper convention by the community, if any? Same question might also be in order for Properties, so I'll leave that open ended.
0
unity onCollisionEnter does not work I know this question has been asked several times but none of the answers solved my problem. I made an sphere and gave it rigidbody. then I draged the sphere on to a new made prefab. on mouse click Instances of this prefab are made and shot. the spheres collide with things in the scene but the onCollisionEnter function is not called. all things in the scene have colliders. I would be grateful if you could tell me what's wrong edited it works if either the sphere or the other object's collider is trigger and I use onTriggerEnter.
0
Why when destroying objects when quitting the game it's destroying the objects only in hierarchy? In one script i did using System.Collections using System.Collections.Generic using UnityEngine public class GameManager MonoBehaviour public LevelGenerator levelGenerator Use this for initialization void Start () Update is called once per frame void Update () private void OnApplicationQuit() levelGenerator.DestroyNodes() Then in the other script public void DestroyNodes() GameObject nodes UnityEngine.GameObject.FindGameObjectsWithTag("Node") if (nodes.Length 0) Debug.Log("No nodes to destroy found") else for (int i 0 i lt nodes.Length i ) DestroyImmediate(nodes i ) But the Nodes still exist in the Hierarchy and in the Game and Scene views. I used a breakpoint it's getting to the OnApplicationQuit And it's getting to the line DestroyImmediate(nodes i ) There are 100 objects and it's doing the line for each object. But then when i make continue they are still exist. I want that when i quit the game stop the play all the gameobjects to be destroyed.
0
Unity Create terrain in Blender? I am going to make a terrain ( not too big ) for my RTS and I was wondering whether to use Unity's terrain tool or create a terrain in Blender and import it to Unity?..I have been told that Unity's terrain is intense work for the mobile GPU..So would it be any good to make the terrain in Blender ( in terms of performance )?
0
How to convert game object world position to hex grid cell coordinates? I have a hex grid and a game object, let's say it's the player. What I want to do is know on which cell the player is on based on his world position, this would be easy on a simple grid but on a hex grid it's giving me a headache.
0
Screen Capture rendered on a RenderTexture in Unity I have a pretty wild idea for a unity application that would work on a multi display setup. The app would be running in full screen mode on one of my displays, and the contents of the remaining two displays should be rendered in game on a texture. I've seen RTMP clients for unity and I've tried streaming my desktop with OBS to a local RTMP server but the delay was too big (more than 5 seconds). I would prefer an instant (or very low delay) solution for mirroring my displays on textures in Unity. If anyone can help me solve this, i would appreciate it!
0
Unity won't slice images properly Okay, so I am very new to Game Development and I imported a .png file(made in Paint) to the assets and that file contains just a circle and an oval, not touching and far apart from each other, both of them coloured blue. When I open the sprite editor and click on splice, then select Automatic and Delete existing options and then click slice, I do not get different sprites, one containing the circle and the other containing the oval. The image isn't sliced at all. I have also set the sprite mode to Multiple, but to no avail. Can someone help me and tell me what I am doing wrong? The engine I am using is Unity. This is the image.
0
GameObject that should have a fixed speed keeps accelerating I'm using a coroutine to make a GameObject move from a random point A to a random point B. The GameObject should move along this trajectory at fixed intervals and at a constant speed. However, each time my coroutine that executes the movement is called, the GameObject is a little bit faster. private IEnumerator movement () Initialize position and rotation float distanceX endTransform.position.x startTransform.position.x float distanceZ endTransform.position.z startTransform.position.z float angleAroundY 90.0f Mathf.Rad2Deg (Mathf.Atan2 (distanceZ, distanceX)) this.gameObject.transform.position startTransform.position this.gameObject.transform.rotation startTransform.rotation Quaternion.Euler (90.0f, angleAroundY, 0.0f) Move from point A to point B while (this.gameObject.transform ! endTransform.transform) float step speed Time.fixedDeltaTime this.gameObject.transform.position Vector3.MoveTowards (this.gameObject.transform.position, endTransform.transform.position, step) yield return null yield return null I checked and the step variable is constant.
0
Attach component of other Object to a variable within Unity Inspector This question might sound a bit stupid and I'm sure there is a simple solution for this .. I'm just not finding it Actually all I want to do is attach the MeshRenderer Component of this Object to a variable of a script on another Object like Problem As soon as you click on the Capsule Object ofcourse the Inspector changes to this Object and I cannot drag in a component to the previous selected Object anymore. I know there are a lot alternatives like linkin only the GameObject e.g. as MeshObject and later in code refer to MeshObject.GetComponent lt MeshRenderer gt but I wondered if this can be done directly, too.
0
Lighting large scene with dynamic lights Unity3D I am working on a game project where most of the action takes place in a large scene that is built to look like a space station. Because it is all technological and enclosed, I can't use a directional light to light the whole scene, and I need to be able to change the color of the lights for an alarm system. I can't bake the lights, because then I can't change their color, and I can't leave them all as dynamic lights, because I have about fifty spot lights, and they take up a huge amount of memory, so much so that the lights can't even render on mobile devices. Is there any way to do this without baking? I am getting about 3000 batches in the Unity Editor Stats on average, in some places it is higher. Even viewing the game in full screen in the editor makes the game run super slow because of the amount of rendering it has to do, and I have a pretty new computer. Here's a picture of my scene (As you can see, it is fairly large as you are able to see the UI box clearly from the scene editor) And here's the Stats box Here is an example of my scene in play mode UPDATE I removed the shadow casting, which isn't necessary for my project, and it improved the framerate slightly, and the batches number is smaller, averaging out at about 1500 now, but the performance still is not optimal.
0
Basic Character Controller Not Working Properly in Unity I've been trying to setup a simple mouse camera which I had all the code working fine, except when I move with wasd and move my mouse to turn the camera simultaneously the input freezes up and gets stuck repeatedly inputting whatever the last input was. I've tested the simplest way to replicate the issue and it doesn't even need a camera for the issue to come up. If anyone would like to test and try to replicate the issue these are the steps its super fast and simple. create new project(basic PC 3D project) create a plane, and a cube Add a basic character controller script to the cube (this time I used the official Unity code to be sure it's not an issue with code) and that's it, that's actually all that was needed to create the issue for me. And to explain to anyone who may want to test it the issue is as follows when you use wasd keys normally, everything works fine and the controls are responsive. However if you hold down one of the wasd keys while also moving your mouse (just wiggling the mouse should suffice) suddenly things will lock up and the cube will keep moving for a bit even after you let go of the respective wasd keys. In general if you hold a direction while simultaneously wiggling the mouse for a longer period of time, it will extend the amount of time the cube keeps moving after you let go of the direction. And this was done on Unity version 2020.1.16f1 If anyone has any idea what the issue may be its really appreciated.
0
Are Differing Store Identifiers Necessary with the Unity IAP Plugin? I am looking at implementing the new Unity In App Purchasing API for the first time. Through the guide and the tutorial, I see that there is the ability to add different store identifiers for product ids that vary across stores... and all the examples reference that way of doing it. Eg. public class MyIAPManager public MyIAPManager () var builder ConfigurationBuilder.Instance(StandardPurchasingModule.Instance()) builder.AddProduct("100 gold coins", ProductType.Consumable, new IDs "100 gold coins google", GooglePlay.Name , "100 gold coins mac", MacAppStore.Name ) In my case, my product id's DONT differ, so this seems like unnecessary code bloat to implement it this way... but I don't see any other option? EDIT Argh, I'm using VS Code on OS X, which is getting better, but still has issues, such as having problematic code completion API referencing issues, so didn't see the overloaded method option... It's simply enough to do this var builder ConfigurationBuilder.Instance(StandardPurchasingModule.Instance()) builder.AddProduct("100 gold coins", ProductType.Consumable)
0
How to enter a level when touching an object I am working on a project in Unity 4.6.1f1 and I was wondering how can I make a cube touch another cube to go to the next level (the image below)? ! EDIT I made a script and put it on the purple cube then enabled "is trigger" on the purple cube, but the blue cube goes right through it. Inspector And the code EDIT 5 15 15 I edited my script and I was wondering if I'm doing something wrong.
0
FPS controller initializing at bizarre location I have got the hang of basic construction, terrain modification, applying materials, placing trees, etc. I have created a water plane, positioned my terrain above it, and am able to sink lakes and pools, and raise hills and mountains. Built a couple of primitive structures too. Initially (before mucking about with the Y position of the terrain) I was also able to invoke Gameplay mode and walk around my game using FPS Character Controller. I could walk into and out of my structures and hike over the hills and valleys of my terrain. However, since changing the Terrain Heightmap to make the "sinkhole" (negative altitudes) work, I am having the strangest trouble with my FPS Character Controller. I position it at a reasonable height above the terrain, and everything looks fine in Editor mode but when I start Play mode my FPS character starts out miles below the world, looking up at the underside of the terrain. So far nothing I have tried will make the FPS Controller start in the location where I have dragged it in Editor mode. I have tried Saving Scene and exiting and reloading. I have deleted and recreated the FPS controller. No matter what I do, it persists in initializing itself in this oddball "way below the world in outer space" location. I have googled diligently but have not found any mention of this problem. Presumably I'm skipping some important step, but tutorial videos don't offer any advice beyond "drag the fps controller into the scene and it should work."
0
Making player movement direction follow players facing direction if (controller.isGrounded) moveDirection new Vector3 (Input.GetAxis ("Horizontal"), 0, Input.GetAxis ("Vertical")) moveDirection transform.TransformDirection (moveDirection) moveDirection speed if (Input.GetButton ("Jump")) moveDirection.y jumpSpeed moveDirection.y gravity Time.deltaTime controller.Move (moveDirection Time.deltaTime) This works. I can manover my player in any direction. With the awsd keys i can create 8 directions. I would like player to rotate towards the direction of the keys pressed. This is a top down game. So W D would take you diagonally right up. S D would take you diagonally right down. I want the player to rotate into that direction, but also move the direction it is facing. Like a car. So if it is facing a complete different direction then it would actually move not in the target direction for a while until it has the target direction. Am i making sense? if (moveDirection ! Vector3.zero) transform.rotation Quaternion.LookRotation (moveDirection)
0
Unity Ads showing test ads I am implementing Unity Ads in my game and for some reason I have the test ads showing up in my production version of my app. I have the advertisements initialized with test ads turned off and I have even gone into my settings on the Unity Ads admin and set it to force test ads to be off. I'm not sure what else to do here. Here is how I am initializing Advertisement.Initialize("myID", false)
0
Get closest Child to cursor I'm currently rewoking my RTS cover system. This should highlight the closest coverspots from my mouse cursor and sent the units to these locations. everything works, but I can't get the closest sport, it always selects the sames ones, regardless to the mouse position. These cover spots are child objects of the obstacle, that has this script attached. This is my not working implementation of the idea void Update() var dist Mathf.Abs(transform.position.z Camera.main.transform.position.z) var v3Pos new Vector3(Input.mousePosition.x, Input.mousePosition.y, dist) v3Pos Camera.main.ScreenToWorldPoint(v3Pos) mousePos v3Pos ... public void getPointDistances() foreach (CoverPosition pos in coverPositions) if (!pos.occupied) pos.distanceToCursor Vector3.Distance(pos.transform.position, mousePos) Array.Sort(coverPositions, delegate (CoverPosition x, CoverPosition y) return y.distanceToCursor.CompareTo(x.distanceToCursor) ) Later, I simply Iterate over the sorted array and make it visisible. I'm woking on this for hours, but i cannot find, a solution why it always displays the same cover spots. I hope, someone can find my (possibly stupid) error. Edit I also tried this, but tata returned always the same values, regardless of my mouse positioning Ray ray Camera.main.ScreenPointToRay(Input.mousePosition) RaycastHit hit if (Physics.Raycast(ray, out hit)) mousePos hit.transform.position
0
How do I create a sphere by script? I want to add a sphere at runtime via script. I have the following code which compiles fine. At runtime however, no sphere is added to the scene. I have attached the debugger to the script, and I have set breakpoints at each line. After the line Material nMat new Material(Shader.Find("Lit")) I'm using the URP the debugger "blanks" out, it doesn't hit the next line. What am I doing wrong? Thank you! using System.Collections using System.Collections.Generic using UnityEngine public class SphereMaker MonoBehaviour private GameObject Sphere void Start() Sphere GameObject.CreatePrimitive(PrimitiveType.Sphere) Sphere.AddComponent lt MeshFilter gt () MeshRenderer nRenderer Sphere.AddComponent lt MeshRenderer gt () Material nMat new Material(Shader.Find("Lit")) I'm using the URP if (nMat null) Debug.LogError("no mat!! n") nMat.color Color.red nRenderer.material nMat Sphere.transform.localScale new Vector3(0.4f, 0.4f, 0.4f) Sphere.transform.position new Vector3(0, 0, 0)
0
How to make Procedual Context Sensitive Mesh Generation during Runtime In the game that i am trying to make i essentially generate an infinitely generating maze that has no dead ends and each corridor is of the same width. i have successfully managed to create this system however once i have created the floor tiles on which you are supposed to walk on i need to generate some walls. these walls surround the floor tiles preventing you from leaving the floor tiles. the system that i have for making these walls right now is very inefficient and redundant so, i would like to find a better way of doing so. my current system for making these walls first, a Floor Builder lays out all the required floor tiles then i have a wall builder game object with numerous empty games objects in a single row that each have a script attached to them that checks if there is a collision on their current tile. if there is a floor tile nothing happens else a wall game object is spawned which is essentially a 1x1x1 cube that has a collider attached to it. once all the checks have been done the parent game object is move 1 tile upwards and the process repeats itself. once the player is out of range of the walls that are left behind a garbage cleaner game object just destroyed them. this system can be improved in terms of code by using arrays instead of multiple game objects however that would still not improve the performance since the cause of the performance drop on slower devices it that a lot of game objects have to be spawned and tracked. the whole system is very inefficient and produces about 100 to 500 game objects which are destroyed later on. i have attached a picture to give an idea of how the system works ignore the cubes and other entities. there are also other solutions i have looked into and made Single line Builder basically, at the boundary, i put a single game object that starts and stops when a player is nearby or not it goes from right to left checking each 1 unit of space for a floor tile and spawning a wall if there isn't. this was a much more efficient but slow solution which i later improved on. Smart Single line Builder its mostly the same as the previous one however once it is in an empty spot it fires a raycast on its left side and when that ray hits a floor tile it uses the information obtained with its current coordinates to make a single row big wall instead of multiple walls this system worked much better but was still so slow that the player is able to run faster than the system can make walls. The kind of system that i would like to have a simple quad that sits below the floor tiles and moves along with the player. the quad is essentially pulled upwards in places where there isnt a floor tile. i have no idea how to make something like this.
0
Splitting a prefab into two These hands are in a single prefab. I want to split this into two so that I can make bones for each of them separately and use them with leap motion. How can make each of these hands as a single prefab? Also, I'm using Unity 2018.
0
Why is my alpha transparency not working correctly in Unity? In Unity I have never seen a bug quite as weird as this one. As usual, I import my texture with a transparent background and then check the alpha is transparency box and apply it, and everything seemed okay. It had worked like it usually does and made the background of my texture transparent. When I apply it to an object or even just paint it onto the terrain it shows the original texture, but in the areas where there should be nothing it replaces it with some nightmarish plaid hell. I have tried other transparent textures but that doesn't seem to work either same result but for each different picture there is a different pattern and color of plaid. I really would appreciate any help I can get on this because I'm just stumped.
0
Long occluding geometries in Resonance Audio for Unity I'm currently looking into using resonance audio (https resonance audio.github.io resonance audio ) for accurately modelling the audio for an environment that approximates to a long corridor with a series of bends. I want to have a sound at the end of this corridor that the user can hear at any point in the corridor based on the sound reflections along the corridor. I have tried a few of the options presented by Resonance Audio Placing reverb probes along the corridor. This seems like the ideal option, however a reverb probe will only apply its baked in reverb profile to sound sources inside the probe. If I try to make the probes larger then they seem to take into account all of the geometry of the corridor at once and things get exceedingly echo ey and consistent regardless of where I am in the corridor. Turning the corridor model into an audio room. This isn't apropriate as it has many of the same issues as a large reverb probe, and also doesn't actually model the space itself. Has anyone had any experience with hearing distant sounds in Resonance Audio environments like this? At this point I have a feeling that Resonance Audio is just not built for this particular situation.
0
OnTriggerEnter is it called in both collider object? I've 2 object a Player and a Bonus object. In both script I've "OnTriggerEnter" script. In Player OnTrigger I Take Bonus value and add it to my Player (health, point, ammo) In Bonus OnTrigger I Play audio (when take it), Play Particle System and so on... But, it seems it's called only Player's OnTriggerEnter ... Why ? In Unity, if I have OnCollision OnTrigger enter in both object, which event is called ? Both ? Thanks
0
How to make procedurally generated terrain look realistic I generated a terrain using a technique from this blog post, everything worked well and I got the wanted result. This is what my generated island looks like As you can see the terrain have a polygon structure. Here is the graph that generated this mesh This is the code used to generate this mesh from the graph void DrawPolygons() List lt Vector3 gt vertices new List lt Vector3 gt () List lt int gt triangles new List lt int gt () List lt Color32 gt colors new List lt Color32 gt () foreach(Center c in centers) float zp zScale c.elevation vertices.Add(new Vector3(((Vector2)c.point).x,zp,((Vector2)c.point).y)) Color c0 getColor(c) colors.Add(c0) int centerIndex vertices.Count 1 var edges c.borders int lastIndex 0 int firstIndex 0 for(int i 0 i lt c.borders.Count i ) if(edges i .v0 null amp amp edges i .v1 null) break get voronoi edge Corner corner0 edges i .v0 Corner corner1 edges i .v1 get vertices height float z0 zScale corner0.elevation float z1 zScale corner1.elevation add color if(edges i .river gt 0) c0 Color.cyan else c0 getColor(c) colors.Add(c0) colors.Add(c0) creat voronoi edge points Vector3 v0 new Vector3(((Vector2)corner0.point).x,z0,((Vector2)corner0.point).y) Vector3 v1 new Vector3(((Vector2)corner1.point).x,z1,((Vector2)corner1.point).y) add points to vertices vertices.Add(v0) var i2 vertices.Count 1 vertices.Add(v1) var i3 vertices.Count 1 add triangles calculating surface normals so i can always add triangles clockwise correctly var surfaceNormal Vector3.Cross (v0 (new Vector3(((Vector2)c.point).x,zp,((Vector2)c.point).y)), v1 (new Vector3(((Vector2)c.point).x,zp,((Vector2)c.point).y))) if(surfaceNormal.y gt 0) AddTriangle(triangles, centerIndex, i2, i3) else AddTriangle(triangles, centerIndex, i3, i2) firstIndex i2 lastIndex i3 calculating uv's Vector2 uvs new Vector2 vertices.Count for (int i 0 i lt uvs.Length i ) uvs i new Vector2(vertices i .x SIZE, vertices i .z SIZE) mesh.Clear() mesh.vertices vertices.ToArray() mesh.triangles triangles.ToArray() mesh.uv uvs mesh.colors32 colors.ToArray() mesh.RecalculateNormals() mesh.RecalculateBounds() meshFilter.sharedMesh mesh meshCollider.sharedMesh mesh I would like to know if it's possible to have a noisy realistic looking terrain from this. How would I implement such a thing? Basically I want something with no hard edges, terrain that looks smooth but not too smooth, something like this video shows
0
Why aren't my Unity Ads showing "real" ads? I don't have quot Enable Test Mode quot checked under in the ads setting in Services, but when ads pop up on my published game, it's showing Unity ads as if the test mode is on. How can I fix this? Thanks! This is the code I use to add the ads Advertisement.Initialize(GooglePlay ID, GameMode) Advertisement.Show()
0
Creating dependent values in the Unity inspector I want to create a few values which will be dependent on each other. Specifically, I want total sum of few values always be 100 In unity inspector no matter how I tweak them. E.G. int total 100 int one 20 int two 30 int three 45 int four 5 How can I make other values adjust automatically if I tweak one of them in Unity Inspector?
0
How do I save variables and load them in Unity with JavaScript? I made a game and i want to save the high score and load it back. I need to save 3 variables and load them when the game starts. How do i do it?
0
Unity built app crashes when using particle system I have scenes with some basic flame effect. Its max particle count is 20 and there are not more than 4 5 instances active on the screen at once. I even checked the profiler but the memory usage was around 150 MB maximum. Given these, all runs fine in the editor but once the particles become visible, the game crashes every time. I tested this on a virtual Nexus tablet. I'm using Unity 2017.1.0p4. If anyone has encountered an issue like this, I'd appreciate any help to get around this. EDIT the built game crashes on PC as well (made a final build for PC, using the same PC). EDIT2 So I was able to trace the issue back to the few following lines var mf transform.parent.gameObject.GetComponentFromParentRecursive lt MeshFilter gt () if (mf ! null amp amp mf.mesh ! null) var sh2 system.shape sh2.mesh mf.mesh return public static class GetComponentRecursive lt summary gt Returns the first Component (T) found on the parent or its children the gameobjects on the same level as this is called on. lt summary gt lt typeparam name "T" gt lt typeparam gt lt param name "g" gt lt param gt lt returns gt lt returns gt public static T GetComponentFromParentRecursive lt T gt (this GameObject g) where T Component if(g.transform.parent.GetComponent lt T gt () ! null) return g.transform.parent.GetComponent lt T gt () else foreach (Transform c in g.transform.parent.transform) if(c.GetComponent lt T gt () ! null) return c.GetComponent lt T gt () return null Please bear in mind that GetComponentFromParentRecursive works, can use it for sprites, no harm done. When I comment out the first few lines, it doesn't crash(just lost functionality). Any ideas why this might cause a crash? And only in built game?
0
How do I parent an object to a bone in the blender hierarchy? So, I'm trying to make a simple RPG game using Blender and Unity. I would like to have an empty object to be used as a weapon holding position parented to my right hand bone so that I can switch weapons in and out and they'll be able to animate along with my character by being the child of the empty position. The problem I am having is that I can't get the empty position to be a child of the specific right hand bone, only the armature. Is there a way to make this work? Also, if this isn't a good procedure to accomplish what I am trying to do, please enlighten me with the proper way, I'm kind of a noob, thanks.
0
Unity order issue with TilemapRenderer.Render I'm using unity, with 2D Tilemaps (I'm doing something like an RPG) I want to have a Tile which should be rendered with a random sprite. When I use a tile like a tree that is bigger than the tile size and RandomTile, the draw order seems to get confused. Even if the sort order on the Tilemap Renderer is set appropriately, some of the tiles are drawing on top of the other tiles with no consistent pattern. After stepping through with the Frame Debugger, it looks like all tiles with the same sprite are drawn at the same Draw Dynamic event under TilemapRenderer.Render. I'm using the following script using System using System.Collections using System.Collections.Generic if UNITY EDITOR using UnityEditor endif using UnityEngine namespace UnityEngine.Tilemaps Serializable public class RandomTile Tile SerializeField public Sprite m Sprites public override void GetTileData(Vector3Int location, ITilemap tileMap, ref TileData tileData) base.GetTileData(location, tileMap, ref tileData) if ((m Sprites ! null) amp amp (m Sprites.Length gt 0)) long hash location.x hash (hash 0xabcd1234) (hash lt lt 15) hash (hash 0x0987efab) (hash gt gt 11) hash location.y hash (hash 0x46ac12fd) (hash lt lt 7) hash (hash 0xbe9730af) (hash lt lt 11) Random.InitState((int)hash) tileData.sprite m Sprites (int) (m Sprites.Length Random.value) if UNITY EDITOR MenuItem("Assets Create Random Tile") public static void CreateRandomTile() string path EditorUtility.SaveFilePanelInProject("Save Random Tile", "New Random Tile", "asset", "Save Random Tile", "Assets") if (path "") return AssetDatabase.CreateAsset(ScriptableObject.CreateInstance lt RandomTile gt (), path) endif if UNITY EDITOR CustomEditor(typeof(RandomTile)) public class RandomTileEditor Editor private RandomTile tile get return (target as RandomTile) public override void OnInspectorGUI() EditorGUI.BeginChangeCheck() int count EditorGUILayout.DelayedIntField("Number of Sprites", tile.m Sprites ! null ? tile.m Sprites.Length 0) if (count lt 0) count 0 if (tile.m Sprites null tile.m Sprites.Length ! count) Array.Resize lt Sprite gt (ref tile.m Sprites, count) if (count 0) return EditorGUILayout.LabelField("Place random sprites.") EditorGUILayout.Space() for (int i 0 i lt count i ) tile.m Sprites i (Sprite) EditorGUILayout.ObjectField("Sprite " (i 1), tile.m Sprites i , typeof(Sprite), false, null) if (EditorGUI.EndChangeCheck()) EditorUtility.SetDirty(tile) endif Is there any way to fix it?
0
Revert a GameObject to a previous version Is there a way to use an old version of a scene.unity file to revert changes for specific GameObjects only? Occasionally Unity GameObjects can lose all their references in the Inspector (If a prefab instance, it keeps the prefabs defaults). I have the missing references committed in my previous git commit, and have not changed any scripts on that GameObjects. If I discard all my working changes to my scene.unity file I get my inspector references back OK. But is there a script or process which allows you to revert specific gameobjects only to HEAD. This would be useful when GameObjects lose their settings, and also when you want to revert only parts of your scene.
0
Are huge, static objects like environment transmitted from server to client in modern multiplayer games? I have an authoritative system, where when the player joins the match, it gets all the already spawned objects spawned on itself (the client). It looks like this Client sends the access token to the Server Client receives the acceptance from the Server Client switches scene to the game scene Server sends players, crates, objects you can interact with so the client can spawn and display them. But what about the ground object? For now, I have the exact same scene on the server and the client with one static plane acting as a floor. Currently I'm adding new stuff, trees, stairs and build things together. I thought we're good. But shouldn't the environment be synchronized too? Be networked somehow? Owned by the server? Let's take League of Legends It's a static environment, probably one combined mesh (stairs, grass, walls, shop). But is it really kept on the client or is it sent by the server during the loading screen?
0
How to Play YouTube Videos Within Asset Store for Unity On every computer I've ever tried to use Unity, the Asset Store seems incapable of showing the YouTube video previews of assets. It always claims my "browser" does not currently recognize any of the video formats available and recommends I click for a visit to a FAQ about HTML5 video. I would expect this to be built into Unity, yet it seems not to be. I can't find anything online about what the deal is. So how do I get the videos to work within the Asset Store within Unity??
0
Matte reflection effect in Unity? I'm trying to achieve that kind of scene but in real time using Unity. It's basically composed of some primitives, a skybox, and a plane. I'm intrigued on how to do this effect in particular The plane acts like a mirror, but tainted and matte (and it appears to be less blurry at the bottom of the buildings... but I'm not quite sure). I have found some shaders to create mirrors in Unity but nothing about the matte effect like in this picture. Could you guide me on how to achieve this kind of effect (knowing that I'm pretty lame when it comes to write shaders but I want to learn). Thanks.
0
"Your android setup is not correct" error on Unity showing up even after reinstalling OpenSSL (Using Facebook SDK) I want to build for Android and today one error popped up after building. Your Android setup is not correct. See Settings in Facebook menu. UnityEditor.HostView OnGUI() Important things about this problem The only error in the inspector I can see is OpenSSL not found. Make sure that OpenSSL is installed and that it is in your path. Even tho I have installed it and added it to my path When I open the inspector in Facebook Edit Settings, unity becomes very unresponsive This error has not popped up before today I still get a APK even if I get errors
0
How to implement a network proximity checker in Unity using LLAPI? I'm trying to implement a network proximity checker using my own functions in Unity, using LLAPI. How can I implemnet a network proximity checker, with similar functionalities than the ones in the HLAPI proximity checker?
0
How to activate GearVR Menu in my own Unity Apps? So in normal GearVr Apps, which you can download from the marketplace, you can activate the GearVr Menu to control brightness etc. with a long click on the back button. But this does not work for all of my apps which I made with Unity for the GearVr, is there something special I have to import into my project?
0
Unity3d UnityWebRequest EscapeURL standard does not match Swift url encoding. How to decode it? How should I decode escaped URL by unity in Swift? I am developing a game with Unity3d. Something MMORPG. With server implemented by me in Swift under Kitura framework A framework doesn't matter that much. It is more about swift and Unity itself. Let me describe the problem here. Unity UnityWebRequest.EscapeURL("First Last") Escapes string with encoding used in the application x www form urlencoded content type https www.w3.org TR html401 interact forms.html h 17.13.4.1 Which produce string First Last where maps to " " space. Swift import Foundation var str "First Last" print(str) print(str.removingPercentEncoding) The character used on this string isn't considered as a percentage encoding in the standard used by swift. It would be if the character escaped as this would be represented by 20. So my server and client ended up with different string values. Later on returned from one to the other weren't equal. Which ended up considering them as two different clients.
0
Spawn Array of GameObjects to Array of Transforms I have a question regarding spawning an array of GameObjects in Unity. What I want to happen is that when a big enemy dies, it will spawn enemies into their respective Transform positions (i.e., Enemy 1 will spawn in Position 1, Enemy 2 in position 2, and so on). I suppose I could go on with something like C public GameObject Enemies public Transform SpawnPoints void KillEnemy() GameObject enemy1 Instantiate(Enemies 0 , SpawnPoints 0 .position, SpawnPoints 0 .rotation GameObject enemy2 Instantiate(Enemies 1 , SpawnPoints 1 .position, SpawnPoints 1 .rotation GameObject enemy3 Instantiate(Enemies 2 , SpawnPoints 2 .position, SpawnPoints 2 .rotation Destroy(gameObject) But the problems are 1. I'm aware that the code is expensive to run, especially since I'm doing a 2D game and 2. It provides no flexibility, meaning if I want a different enemy to use the same code, then I won't be able to do stuff like adding more enemies to spawn (after the first one dies, of course). So yeah, I hope I get some help with this. Thanks!
0
Updating the position of a prefab in Unity for A pathfinding I am trying to use Aron Granberg A pathfinding project in my game. I am very new to Unity, so I am having some trouble figuring out how to instantiate multiple enemies from a prefab that will seek out my player. I am unable to set the player object from the scene as the target, since prefabs cannot take in scene objects. However, if I use the player prefab as the target, the enemies will only go toward the starting position of the player. Is there any way to update the prefab position as the player instance moves? Or is there a better way of doing this? I want this to be a top down shooter style game (2D) with constant enemy spawning, so it doesn't make sense to set the target for each individual enemy instance. Any help would be greatly appreciated. Thank you!
0
How to make an animation play when a button is pressed once? I have added an idle and jump animation to a character in unity. I can make the animation happen when the button is pressed. If the button is up middle at the animation the character goes to the idle position. But I want the whole animation happen in one press to the button and then go back to the idle position. My current script and Animator views are if (Input.GetKeyDown(KeyCode.Space)) Anim.SetBool("is jumping", true) ApplyInput(moveAxis, turnAxis) else if (Input.GetKeyUp(KeyCode.Space)) Anim.SetBool("is jumping", false)
0
Programmatically create a trigger within abnormally shaped room So I'm trying to create a trigger in each of my rooms. These rooms can be created by players. Basically, I need to know all the objects in a room. These rooms can be shaped in weird and wonderful ways. I'm struggling to figure out how to "fill" an area? The other problem is that some walls are curved. My current thinking is Loop over all the walls in a scene. Do 4 raycasts from each side of the wall and see if we hit other walls. If we do, we are likely in a room. From the offset, literally check each node adjacent to that until we fill the room. Once I have this though, Im not sure what to do with it. How do I create bounds that I can check for collisions with this data? Edit Adding an image for clarity. Red and blue should be 2 different rooms and I want to get all items in each of these rooms
0
How to use a Rigidbody on a game object after animation in Unity? How to use a Rigidbody on a game object after animation in Unity? I want to play an animation fully controlling the positioning of the elements, i.e. ignoring physics. And after an animation plays till the end I want physics to resume affecting the element. Right now to get the expected behavior I have to remove the Animator after an animation. I thought that maybe there is a neater way to do what I want, but I did not find it, so decided to ask here. UPDATE I just found a better way to achieve what I want. Instead of removing the Animator component I just disable it animator.enabled false It feels better. But still I am hoping for a neater solution.
0
How can I instantiate in the current rotation in Unity 2d? Backstory I'm currently working on a 2D sidescroller platform game as a hobby, and I just started recently. Followed a few tutorials and such I managed to wrote my own code for basic command like walk, jump, health and so on. However my basic code wasnt perforning as I would expect, I needed a more "Tight" feeling with the movements so I followed a suggestion to use a physics based controller (Prime31's PC2D, Acrocatic or even Corgi Engine...) Well, now the movements are what I feel is good, So I kind of dived in the scripts to add remove customize some code. Question I'm stuck now on a simple issue, I added these lines public Transform weaponMuzzle public GameObject projectile float fireRate 0.5f float nextFire 0 then in my Update() if (Input.GetButtonDown("Fire2")) animator.Play.Weapon() fireProjectile () and here is the problem I have void fireProjectile () if (Time.time gt nextFire) nextFire Time.time fireRate if ( motor.facingLeft) Instantiate (projectile, weaponMuzzle.position, Quaternion.Euler (new Vector3 (0,0,180f))) else if (! motor.facingLeft) Instantiate (projectile, weaponMuzzle.position, Quaternion.Euler (new Vector3 (0, 0, 0))) The prefabs are also physics based and they are fired with no problems, however they don't want to follow the current rotation of the player, they always go in the right X axis. First of all, the facingLeft on my code is what I understand is the reference to the character controller motor, I tried with motor.normalizedXMovement gt 0 and motor.normalizedXMovement lt 0 (normalizedXMovement 1 is full left and 1 is full right) this just make it that you can only fire while moving, not stopped and the problem still persists. I also tried with Quaternion.Identity instead of Euler and it's the same. For a full source code https github.com prime31 CharacterController2D I'm kinda lost and it would means a lot if you can help me out on this issue. Ps I already searched here and other related forums but cannot find the answer, this is not a repost.
0
Replacing assets in Unity real time but keeping the references intact I'm looking forward to adding mod support into my game by allowing users to easily replace some assets with their own versions. The way I want it to work if there's, say, a certain texture in some folder in my compiled game, I replace the texture with the same name in my resources, but I keep references intact. That means that the texture will be replaced for every material using this texture. I don't want to change materials themselves to reference the new texture, mainly because I'll have to keep a list of materials for each texture, and because materials might be replaced by potential modder as well. It's also important to note that I want to give people the ability to change basically anything (but scripts). Sounds, music, textures, meshes, materials, fonts, localization files, shaders, so the list of references might be absolutely changed upside down and that is absolutely not the solution.
0
Share a function between two passes inside CG Shader for unity3d I'm writing a shader in CG language for Unity3d. When making transparent object you need to create two similar passes in SubShader. First to render only back faces (with Cull Front) and second to render only front faces (with Cull Back). But the code for vertex and fragment function is the same. Is it possible not to double a code and declare some functions, that would be shared between passes? I want to have something like in my code example. Shader "cool shader" Properties ... SubShader CGPROGRAM need to declare vertexOutput somewhow here float4 sharedFragFoo(vertexOutput i) COLOR How to make smth like this? .... return float4(...) ENDCG pass CGPROGRAM pragma vertex vert pragma fragment frag vertexOutput vert(vertexInput v) vertexOutput o ... return o float4 frag(vertexOutput i) COLOR return sharedFragFoo(i) call the shared between passes function ENDCG pass CGPROGRAM pragma vertex vert pragma fragment frag vertexOutput vert(vertexInput v) vertexOutput o ... return o float4 frag(vertexOutput i) COLOR return sharedFragFoo(i) call the shared between passes function ENDCG
0
Unity adding camera constraint to prevent the player from seeing beyond the scene Like the title says, I'm after some kind of constraint for the camera to prevent the player from seeing beyond the scene and seeing the Skybox. I came across the code to add a Mathf.Clamp, but I can't get it to work. I'm currently trying to make a 2.5D platformer in which the camera follows the player (ahead), which leads to seeing beyond the scene to the far left and right. I already have an invisible wall in place to prevent the player from falling off, but I would love to also clamp the camera from going any further. This is the script I have at the moment using System.Collections using System.Collections.Generic using UnityEngine public class CameraController MonoBehaviour SerializeField GameObject player null SerializeField Range(0.1f, 2f) float followAhead 2f SerializeField Range(0.1f, 2f) float smoothing 1f public PlayerController playerController private float minPosition 9.37f private float maxPosition 4.68f private Vector3 cameraClamp const float m minY 2f Vector3 targetPosition Vector3 cameraOffset void Start() cameraOffset transform.position player.transform.position void Update() targetPosition (player.transform.position (player.transform.forward followAhead)) cameraOffset smoothedForward Vector3.MoveTowards(smoothedForward, playerController.GetTravelDirection(), 0.5f Time.deltaTime) targetPosition (player.transform.position (smoothedForward followAhead)) transform.position player.transform.position cameraOffset targetPosition.y Mathf.Min(targetPosition.y, m minY) transform.position Vector3.Lerp(transform.position, targetPosition, smoothing Time.deltaTime) cameraClamp.x Mathf.Clamp(transform.position.x, 9.37f, 4.68f)
0
Continuous translation in Unity I would like to apply a constant speed everlasting translation to a game object (e.g a background) in Unity. Without physics. What is the best way to achieve that?
0
How can i properly display 2D Pixel sprite's pixels without distortion while it's moving ? (in unity) Introduction to what i'm trying to do Hi, I'm trying to make a 2D Pixel Platformer Game in Unity. Before that i used godot and for some reasons (not about the engine) i switched to unity. And in Unity there are things need to handle by myself, and they were handled by the engine in godot (i guess), because godot is more suitable and compatible with 2D Pixel games (i guess). So i am not sure why the problem happens The Problem In the scene, my pixel sprite is playing his Idle animation (he's only breathing so you can think of that as head and the body moving 1px up and down repeatedly) While playing that simple animation, if my sprite is big enough on the screen, there is no problem and it looks pixel perfect animation is playing without distortion (or disruption idk what was the right word). But if the character looks smaller on the screen, i mean if i scale the character down or keep the scale same and make camera's angle of view bigger, so character looks smaller (not too small a regular platformer character size), What happens is character's eyes visibly goes thinner and thicker as the character plays his animation (head and the body moving 1px up and down repeatedly). Character's eye is 2 black pixels side by side thats it. While the animation playing it kinda distorts. Height changes. Yes I fixed it somehow but.. I fixed it, but idk how and seems like a temporary fix AND i don't think that is how it's supposed to be fixed because we wrote code, I'm okay with writing code for fixing it but first i want to know what was the problem and how to fix it in editor. aaand it just seems weird to write code for simply having a properly functioning pixel sprite animation. How did i fixed it ? just watched this video and added the same script to the camera i have no idea how it worked and why my animation problem was occuring at the first place. What I'm asking for Pleaaaase somebody explain all that to me, why is that happening what are the possible and proper fixes. i'm researching for days and i thought unity had a "big community a lot of tutorials too easy to learn" TL DR when playing animation pixel sprite character's some pixels distorts version Unity 2019.3.3f1 I imported sprite the right way (Filter mode Point(no filter) Compression none, Pixels per unit 16 (that option seems suspicious maybe the problem is about that pixels and units thingies)) I can provide more information about project or directly send you the whole project if you can't reproduce the error. I'm just too curious and want to learn how to have a proper 2D display setup and finally start the fun part coding mechanics etc. since a code about camera solved the issue the problem might be unity's camera settings because unity has no 2D special camera component while godot has Camera2D and Camera3D seperatly. These are just my guesses please teach me what you know.
0
Placing a gameobject with restrictions I am newbie in programming and I am making a tower defense game 2d. My problem is I want to make a restriction to place a tower only, if the mother tower is in place or within its range. I'm sorry if my explanation is a bit confusing. For example, you can oly place a certain tower within the range of the mother tower and only if that mother tower is placed. I don't exctly know if I have to create a function for this or create a range game object for the placement attached to the mother tower. Any help and tips would be appreciated, thank you. This is by the way unity C .
0
Unity Custom aspect ratio in build I have made a game that was supposed to be for mobile but now I need to build it for PC. I want the aspect ratio to be 2 3 but as you can see on the image that doesn't exist. How do I add a custom aspect ratio for the build?
0
Unity3D HTC Vive graphical bug when making builds Recently I noticed that my builds seem to have a weird graphical bug. This only occurs when I play a build. Running the game in VR in unity play mode doesn't show this bug. I am not sure what is causing this or what it is even called. I do remember in the old days windows having a similar bug where you could draw on your screen basically by dragging an interface. I have an older build where this glitch didn't occur and checked the settings I had then and now and nothing changed. Developing in VR is still fairly new to me so if it is anything basic I might not be aware of it. My Unity version is 2017.2.0f3 with the latest SteamVR version using the HTC Vive, which has been running on the same version as when the bug didn't occur. This link is a video of the bug occurring during the play mode in a build (in the menu the bug didn't occur strangely enough). This link is a video of it being run in play mode. This is what I would expect in a build as well. Just watching the first few seconds of both videos is plenty to understand the issue I am experiencing. Thanks in advance. Edit I have discovered that this issue is called ghosting. I hope this helps anyone.
0
Move gameObject in its facing direction I have the following four gameObjects, they have, respectively, the rotations 90, 0, 90, 180. I want them to move as denoted in the image below This is what I got so far public class Projecttile MonoBehaviour public float speed private void Update() transform.Translate(transform.up speed Time.deltaTime) The result of my code is the following Why does my code result in this outcome, and how can I make each gameObject move in the direction it's facing?
0
How to determine what direction an object should orbit around another I am creating a game in Unity with 2D. When a button is clicked a static object is attaching a hinge joint to a dynamic object, so the dynamic object orbits it. When the dynamic object gets attached, I am setting the dynamics objects transform.up vector to be pointing at the static object. Then, taking what ever the dynamic objects magnitude was and setting that as its velocity to the right. I do this because I want the dynamic object to orbit the planet at the same exact speed as when it wasn't orbiting. The problem I am having, is I don't know how to determine if the object should orbit clockwise or counter clockwise. It's easy for me to determine this when I look at an image, but I don't know how to via code. Here is an example Does anyone know how I can determine this?
0
How should I store and load structures for 2d tile based game? I am working on structure generation for my 2d tile based game. Structures can be anything from houses, castles, dungeons, mazes etc. Structures are pre defined, meaning I defined the width height of the structure and wrote every single tile that should be placed for each coordinate. Structure "template" public class Structure private int width private int height private int , element public Structure(int w, int h, int , e) width w height h element e Creating a new structure 0 air 1 wall 2 door Structure house new Structure(4, 4, 1, 1, 1, 1 , 1, 0, 0, 1 , 1, 0, 0, 1 , 1, 2, 1, 1 ) This works fine for small amounts of structures. However, having tens hundreds of structures in code is not only mess, but taking memory unnecessarily since structure generation gets called rarily. So how should I store that data? 1) Should I make a file for each structure and load from it? 2) Should I dump all structures in 1 file? 3) What file format should I use for this? 4) Does Unity provide some data containers that can be easily accessed and read from? 5) How is this usually done?
0
Unity Photon multiplayer check distance between two players How to get distance between two player in a photon multiplayer game. Condition is both the player is moving. I have tried something like this, in my player control script if (photonView.isMine) pos1 rigidBody.position else pos2 rigidBody.position Distance Vector3.Distance(pos1 pos2) But its not working. For a player the pos2 is always (0,0). Please help.
0
2D active ragdoll physics based procedural animation I'm trying to make a 2D quadraped robot stand and walk via physics. My robot looks like this. (art is not mine. Source is vapgames) It's rigged via Unity's 2D animation package and each joint bone has it's own collider rigidbody with the legs also having hingejoints connecting the lower part to the upper part and the upper part to the main body of the robot. I've also set up IK for both legs using the 2D IK package with the IK target being attached to their respective leg via fixedjoint and can be moved programmatically to move the legs with respect to IK. I want it to stand up, as at the moment is just falls and acts as a generic limp ragdoll. I've tried these methods Adding downward force to the legs via the IK targets Adding upward force to the torso Animating the IK targets to try and get the bot to stand up with animatePhysics enabled. All of these failed (downard force to legs did pretty much nothing, upward force to torso just made it float if there was no ground, animating the IK targets was too glitchy). I'm out of ideas on how to actually do this now. I've looked around for guides but there seems to be nothing good (I keep getting this suggested to me but it doesn't help. It's in 3D and the only thing that could help, spider legs, isn't finished and probably never will be) There's very little information on how to do this sort of stuff and even when I find people who know about active ragdolls they just say add force to the head (for a 3D active ragdoll), which I've already tried (see 2. on the list of what I've already tried) and don't explain anyt further. If anyone could help, that'd be great!
0
Unity Ragdoll moves away from parent So this is a weird one. I've looked it up but can't find anyone with similar issues. Basically I have a simple combat system and after the enemy health is zero I go through each rigidbody component in the enemy object and add a force to make it go flying on death. For some reason, the parent object isn't affected and stays still while the Skeleton goes flying. Does anybody know how to make the parent object follow the skeleton, or make the skeleton follow the parent because as of now they act as separate entities? I've tried just adding force to the parent but that only moves the parent object and none of the children. Would appreciate any advice! Thanks.
0
Unexpected scaling of UI elements after build Unity Web I have an unusual scaling of UI Elements after my build in unity for WebGL Game in Unity Engine Game in Itch.io Has anyone seen this kind of behaviour? any suggestions on what I should look into? Happy to provide more info on the matter. Thanks!
0
How to ignore one unity package in source control I've just installed the Unity quick search package. This is an editor extension which each developer should choose if they want installed or not. My problem is that because this was added as a package it also made changes to my project which would end up in our repository. The changes are Project root Assets Assets.index Assets.index.meta Packages manifest.json packages lock.json UserSettings QuickSearch.settings Questions Should this files be added to source control? How can I ignore the changes in manifest.json and packages lock.json without filters?
0
Is triangle count so much cheaper on hard surface models that on animated meshes? I have a human character that consists of 40k triangles. When I animated him, I noticed a huge impact on the frame rate. Then I created a 10k tris version of the same model and animated him, and the frame rate was significantly higher. I would like to ask if there is any formula or any other way to compare this situation with a high poly model of a hard surface model against a low poly version of a hard surface model. For example, I see some 3D model vendors that offer weapons for FPS games, and they call their weapons with 25k tris "lo poly". Am I missing something here? Is it really so cheap (for some reason that I haven't found out) to throw 25k of hard surface geometry to CPU or GPU, and it wouldn't make a noticable difference in comparision to a 3k tris hard surface model? I'm working with Unity and HDRP, if that is important for an estimation. Thank you.
0
Best way to store items with statistics in an mysql database? Im currently working on an multiplayer game. Therefore using MySql for my game to store different data ( For example players, resources and so on ). Lately i implemented items, players receive them by gathering resources for example, later they should also be able to craft them or even equip them if its a sword or an armor piece. My problem is that due to my small experience with MySql, i have no clue how to add different statistics ( Equipable, Damage, Different Effects and so on ) to the items. Not every item should have them ( For example "Wood" shouldnt have statistics ). How should i modify my tables ? Any help would be appreciated ! Thanks ! My current table structure looks like this ItemCategories ( ID, Name ) ItemTypes ( ID, Name, ItemCategories ID ) For more information, how i actually manage spawn those items in... here two more important tables. This table contains resources ( For Example "Basic Tree" ) and the item it drops when gathered. Resources( ID, Name, ItemTypes ID, gatheringTime, gatherAmount, spawnWeight) This table contains the items in the players inventory. PlayerInventory( ItemTypes ID, Player ID, amount)
0
Export normal map from unity? In unity I can create a normal map out of a black and white image (By changing the type to normal map and select create from grayscale) Im wondering if there is a way to export the normal map like it should look so I don't need to create it from grayscale when I use it in another project?
0
How to find 1 3 and 2 3 of the distance between two given points? I know how to find the middle of two given points var midpoint (pointA pointB) 2 where pointA and pointB are Vector2 I thought that var thirdBtnPoints (pointA pointB) 3 var twoThirdBtnPoints 2 (pointA pointB) 3 should give me 1 3 and 2 3 between the two points but it doesn't. I guess this might be more of a math question though, but how can I find 1 3 and 2 3 of the distance between two given points?
0
Unity is Single Thread by how do WWW with coroutine work Async When I used HttpWebRequest and HttpWebResponse classes for an API calling my game suddenly halt for some seconds but as i used same API calling through WWW with coroutine, it didn't halt. I heard that unity is single thread but why my game not halt as i used WWW with coroutine? and is i am getting right that HttpWebRequest and HttpWebResponse are not better than WWW?
0
How to retrive the original position of an axis to Vector3? float x Random.Range( 1f , 1f) magnitude float y Random.Range( 1f , 1f) magnitude transform.localPosition new Vector3(x, y, originalPos.z) Here I'm trying to retrive the original position of z(without any changes) to the vector3. But in visual studio 2017 is showing an error like this How to resolve this?