Tag Info

New answers tagged

1

You could sum it up like such: Pre-game install: You can't assume they are there. Post-game install: You can assume (hope) that the XNA 4.0 Redistributable installed correctly and the assemblies reside in their respected locations. If the scripting that the user will be doing is tested and run solely in game, then I would think that this is a safe route ...


0

Try something like this public Vector2 jumpDirection = new Vector2(0f, 1f); public float jumpFocre = 500f; //... float move = Input.GetAxis ("Horizontal"); jumpDirection.x = move; GetComponent<Rigidbody2D>().AddForce(jumpDirection.normalized * jumpFocre); In this way you are giving to the jump force the x component that the user rare triggering in ...


1

Your code currently contains : public float jumpFocre = 500f; //... GetComponent<Rigidbody2D>().AddForce(new Vector2(0, jumpFocre)); Rigidbody2D.AddForce() takes a Vector2 as a parameter, so this can be changed to: public Vector2 jumpDirection = new Vector2(0f, 1f); public float jumpFocre = 500f; //... ...


0

In update, you just check if the character is on ground and set desired velocity. Example, if you want character running forward, rigidbody2d.velocity=speed. Where speed is a vector2 of specific value e.g: (3,0).


2

void FixedUpdate() { ... if (grounded) doubleJump = false; static float move; //Only allocate memory once move = Mathf.Max(Input.GetAxis("Horizontal"), 0); //New; nullify negative values //move = Input.GetAxis("Horizontal"); //Old; positive and negative anim.SetFloat ("Speed", Mathf.Abs (move)); ... } or void FixedUpdate() { ... ...


1

This has been discussed a few times in Unity's forums. This thread has a long discussion about the issue, and this and this Unity answers posts. If you don't solve it and everything seems to work fine, I suggest submitting a bug to Unity. Remember this is a warning, so it is possible that even though you see it everything will work well. Usually it happens ...


0

C++ and C# can interact quite easily. (In the practice C++ issues relative to name mangling often force to have an intermediate C layer) There are several resources you can have a look such as Mono P/Invoke docs and unity docs on native plugins. Calling a C# function from C++ code is simply as using a function pointer (a C# delegate can be marshalled to ...


0

Unity uses its own messaging system to call methods like Update. You can use it as well with for example Component.SendMessage. I think that the underlying implementation of the message system uses some form of reflection to determine what methods a class has and call the appropriate ones. (This post's answer explains it better)


1

Scripting languages often expose a set of API functions that allow you to inspect and determine attributes about a loaded script, in your case what functions are defined. This varies by scripting language naturally and will also depend on your native language to scripting language bindings. In Lua for example, I can load a script and then check whether a ...


0

The state of the Shift key is checked in the ThirdPersonUserControl.cs script which isn't that difficult. To just swap the states you most likely (I haven't checked it!) would need to replace the #if !MOBILE_INPUT // walk speed multiplier if (Input.GetKey(KeyCode.LeftShift)) m_Move *= 0.5f; #endif with m_Move *= 0.5f; // Do it ...


0

I seems to me that Awake is called when the object is loaded when scenes change, in that case you explicitally call destroy.


3

Check if your gameObject has a parent object in the hierarchy. If it has, then everything is as intended. Your object itself isn't explicitly destroyed by Unity. But its parent may very well be destroyed. It is to be expected that when an object is destroyed, all of its children are destroyed too. That's when your object is destroyed. Put your object in ...


1

Presuming you've saved the prefab out to your Resources folder in your project, you will need to load and instantiate it and then attach it to the canvas. Your code should be something like this: Canvas canvasComponent = GameObject.Find("Canvas").GetComponent<Canvas>(); GameObject myButtonPrefab = ...



Top 50 recent answers are included