Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

Search the Community

Showing results for tags 'javascript'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • GENERAL
    • Introduce yourself
    • Discussions
    • Showcase
    • Need help?
    • Seeking team members?
    • Offtopic
  • RESOURCES
    • Example Projects
    • Scripts
    • Shaders
    • Unity Tutorials
    • FPS Kit Tutorials
    • 3D models
    • Animated 3D Models
    • Graphic design
    • Textures
    • Sounds
    • Other
  • SELL | REQUEST
    • Sell
    • Request
  • Mars' Modular Multiplayer Photon FPS Kit's Topics
  • Mars' Modular Multiplayer Photon FPS Kit's Reviews
  • Mars' Modular Multiplayer Photon FPS Kit's Updates
  • Mars' Modular Multiplayer Photon FPS Kit's Tutorials
  • Busy People's Introductions
  • Photon's Tutorials
  • Photon's Photon General
  • Photon's Showcase

Categories

  • Free Projects
  • Free Assets
  • Game Demos
  • Photon's Files

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


YouTube URL


Facebook URL


Twitter URL


IndieGoGo URL


Kickstarter URL


IndieDB URL


GreenLight URL


Location:


Interests

Found 54 results

  1. Hey ArmedUnity community, I worked on a Unity project for a long time and I have write the most script's in javacodes so JS (Javascripts/unityscripts), but now I made a mistake. I would convert one Javascript Unity project to C# scripts with a script converter tool, but the converter has convert all my javascripts in my primary Unity Project to C# scripts too. Now I don't have a backup from my primary project Javascripts, so all my javascripts are converted to C# scripts (my game project don't work anymore). But I have build my game a day ago, so I have now downloaded "dotPeek" the tool can decompile .dll files and can export scripts. The problem is, it can only decompile all scripts to C# not to javascripts. I have only two scripts written in the c# language, the rest is written in JS, so JavaScript/unityscript. Now, I need your help: - My question is, is there a way to convert all the C# scripts back to my javascripts? - Or the better option: Is there a way to extract the js (Javascripts/unityscripts) from my builded game? Here are a picture from the two c# scripts in my builded game(I can export my c# scripts perfect with "DotPeek" or any export tool, but not my javascripts): https://image.ibb.co/dWJp1n/c_scripts.png And here are a picture from my Js (Javascripts/unityscripts). If I open my builded game with any decompile tool, will any program convert my javascripts to c# scripts automatically. So this picture is made in "DotPeek" too: https://preview.ibb.co/eyvV7S/javascripts.png Thanks, -ImHaxoTV aka Florian
  2. Hi guys , i want help on how to make realistic shell ejection in javascript, i know i rarely use javascript since im a c# guy but since this will be added on OMA's weaponScriptNew then i need it on JS.. Here is my current one : //Shell script var bulletshell = Instantiate(bulletPrefab,shellspawn.position, bulletPrefab.rotation); bulletshell.rigidbody.AddForce(transform.up * 80); bulletshell.rigidbody.AddForce(transform.right * 140); my problem, i want to be MORE realistic and add some smooth rotation on it ... Any help would be appreciate
  3. Hello! I am a noob, with no formal education, so, I really appreciate these free FPSKits! They're great for learning, awesome for noobs like myself. I'm using the FPSKit v1.3.5 written in Unity Javascript. The issue I'm having is with the GUI elements. (ex. health, ammo, score, etc.) I simply want to move them to the top center of the screen. But, the only GUI experience I have is with the new Unity GUI Canvas etc. I think I have to change the "Rect Width/Height values". But, I'm not sure where?? Any help is greatly appreciated. Thanks.
  4. Version 0.1

    27 downloads

    A text file containing a JavaScript which assigns a random colour out of six choices. Copy and pasta this into MonoDevelop or whatever. Replace R, G and B in the declarations to get your own custom colours and not errors. Example: Color(R, G, B ) into Color(0.41,0.51,1.59); a cool blue. I recommend using www.colorpicker.com for finding RGB values. Be sure to divide the RGB values by 100 and make them float. haha It's a bit of hassle, but I just wanted to share it with the community.
  5. I Need A Gun Script That I Can Modify For A Pistol, Assault Rifle, Sniper Rifle, Lmg, Smg, Etc; PM Me Here Or Respond To The Topic, Thanks.
  6. Hi guys. I want to convert a CSharp code to Javascript. It's possible ? The code (CS) : Hashtable setPlayerKills = new Hashtable() {{"Kills", 0}}; PhotonNetwork.player.SetCustomProperties(setPlayerKills); Hashtable setPlayerDeaths = new Hashtable() {{"Deaths", 0}}; PhotonNetwork.player.SetCustomProperties(setPlayerDeaths);
  7. Hey, I've been doing this code for my game that lets you dynamically travel in time so you can control what year you're currently in. It works fine, and certain objects will appear and disappear depending on if they exist in the time you're in. However, what I'm trying to do is make it so that if you move a rigidbody in say the year 1000 and then travel to the year 1100 and move the rigidbody, and then travel back to 1000, the rigidbody would return to the position it was in back in the year 1000 because that was where it was in the past and return to the position it was in in the future (1100). The script for the objects affected by time is below. I appreciate any help I can get. I've tried to word this as well as I can but I'm still not too sure if this makes sense. Thanks for any help. This is the script for the objects affected by time travel. var timeHandler : TimeManager; var existantAt = 100; var nonExistantAt = 300; private var startX : float; private var startY : float; private var timeOfChange : int; function Start(){ startX = transform.localScale.x; startY = transform.localScale.y; //Do After transform.localScale.x = 0; transform.localScale.y = 0; canSetCurPos = true; if(rigidbody){ rigidbody.isKinematic = true; } } function Update(){ timeHandler = GameObject.FindObjectOfType(TimeManager) as TimeManager; if(transform.localScale.x == startX && transform.localScale.y == startY){ if(rigidbody){ rigidbody.isKinematic = false; } } //Check if the object exists in the year you're in if(timeHandler.time > existantAt && timeHandler.time < nonExistantAt){ Exist(); } if(timeHandler.time < existantAt || timeHandler.time > nonExistantAt){ Nonexist(); } } function Exist(){ collider.enabled = true; transform.localScale.x = startX; transform.localScale.y = startY; } function Nonexist(){ if(rigidbody){ rigidbody.isKinematic = true; } collider.enabled = false; transform.localScale.x = 0; transform.localScale.y = 0; }
  8. gameObj = PhotonNetwork.Instantiate(availableObjects[i], gameObject.transform.position, Quaternion.identity, 0); The codes up above ^ Hey, i am currently trying to make a level editor in my game, and i have got stuck on some code. Heres the error: No appropriate version of 'PhotonNetwork.Instantisate' for the argument list '(UnityEngine.GameObject, UnityEngine.Vector3, UnityEngine.Quaternion, int)' was found. Any help is greatly appreciated
  9. Well.. I was trying to add health regeneration to FPSKIT for a while without luck... Finnaly got it to work with the help of "Grifto" So here is how to do it In the variable section add var loop : boolean; Then replace the update function with function Update(){ if (time > 0){ time -= Time.deltaTime; } alpha = time; } if(hitPoints < maxHitPoints && !loop) { Regen(); } Then right down the bottom of the script add a new function. function Regen(){ loop = true; yield WaitForSeconds (1); hitPoints ++; loop = false; } Now You have health Regeneration at +1 health every second, Or You could change the yield WaitForSeconds (1); With someone More suitable for your game.. Hope you guys find this helpful Have fun!
  10. hi guys I need your help with a script I'm trying to create I'm making a game like that for my moba player shoot have to click the enemy (minion) but when clicking, I get error function to call, I'm working with javascript here is my script: #pragma strict var Minion : GameObject; var projectile : Rigidbody; var speed = 20; function Start () { } function Update () { } function OnMouseDown (Minion : GameObject){ if( Input.GetButtonDown( "Fire1" ) ) { var instantiatedProjectile : Rigidbody = Instantiate( projectile, transform.position, transform.rotation ); instantiatedProjectile.velocity = transform.TransformDirection( Vector3( 0, 0, speed ) ); Physics.IgnoreCollision( instantiatedProjectile. collider, transform.root.collider ); } }
  11. someone will have a script for the enemy patrol and if you see me (player) attack me and been trying to make one but nothing gives me many errors and I searched the net but have had no luck. support for the enemy ai I've been learning some java script, leave my script for you to see and if they find several erroes please let me know my script: # pragma strict var targetCollider: GameObject; var targetBoolean: boolean = false; var enemy: GameObject; var Attack: AnimationClip; // Deve equal the name of the animation var Idle: AnimationClip; // Idle animation var Run: AnimationClip; // animation run var speed: float = 5f; var wp1: GameObject; var wp2: GameObject; var wp3: GameObject; var WP4: GameObject; function Start () { } Update function () { if (targetBoolean == true) { Debug.log ("I see"); animation.Play ("Attack"); // remember the name of the animation as animation clip arrives } else { Debug.log ("pa where you left"); animation.Play ("Idle"); // idle animation } if (targetBoolean == false) { Enemigo.transform.position = Vector3.Lerp (Enemigo.transform.position, wp1.transform.position, Time.deltaTime * speed); } } OnTriggerEnter function (targetCollider: Collider) { targetBoolean = true; } OnTriggerExit function (targetCollider: Collider) { targetBoolean = false; }
  12. Hi guys !!!! Step over here to help me because in unity forum leave me not to publish my question could someone tell me how to do that or gameobject moves to another object (the coordinates of the other object)? someone could make me an example using java script?
  13. I want a script where the detector prioritize first the first detector and continued up to the sixth detector I want it to be in a tag mode but I don't know where to start
  14. Hello. Can you tell me where to learn scripting, javascript prefer. Thanks
  15. I want to make a tilt effect on my object
  16. How can I make a collider of tags which will count only once !
  17. mgudoy

    Countdown Timer

    #pragma strict private var startTime : float; var textTime : String; //First define two variables. One private and one public variable. Set the first variable to be a float. //Use for textTime a string. function Start() { startTime = Time.time; } function OnGUI () { var guiTime = Time.time - startTime; //The gui-Time is the difference between the actual time and the start time. var minutes : int = guiTime / 60; //Divide the guiTime by sixty to get the minutes. var seconds : int = guiTime % 60;//Use the euclidean division for the seconds. var fraction : int = (guiTime * 100) % 100; textTime = String.Format ("{0:00}:{1:00}:{2:00}", minutes, seconds, fraction); //text.Time is the time that will be displayed. GetComponent(GUIText).text = textTime; } I'm confused how can I use this timer to count backwards? :/ Help!!
  18. Hey Guys , After fixing my Locked Door Script i want to share it with you bro's , now u can use multiple keys and doors LockedDoor Script : var IsOpen : boolean = false; var CanOpen : boolean = false; var NeedKey : boolean = true; var DoorInt : int; var Locked : AudioClip; var Open : AudioClip; var Volume : float = 0.5; var KeyScript : GameObject; function Start () { audio.volume = Volume; } function Update () { if(Input.GetKeyUp(KeyCode.E) && !IsOpen && CanOpen && !NeedKey) { Opening(); IsOpen = true; audio.clip = Open; audio.Play(); } else if(Input.GetKeyUp(KeyCode.E) && IsOpen && CanOpen && !NeedKey) { Closing(); IsOpen = false; } else if(Input.GetKeyUp(KeyCode.E) && CanOpen && NeedKey) { audio.clip = Locked; audio.Play(); } if(KeyScript.GetComponent(Key).HaveKey == true) { NeedKey = false; } } function Opening() { for (var i = 0; i < 100; i++) { transform.Rotate(0,0.9,0); yield WaitForSeconds(0.01); } } function Closing() { for (var i = 0; i < 100; i++) { transform.Rotate(0,-0.9,0); yield WaitForSeconds(0.01); audio.clip = Open; audio.Play(); } } function OnTriggerEnter (other : Collider) { if(other.gameObject.tag == "Player") { CanOpen = true; } } function OnTriggerExit (other : Collider) { if(other.gameObject.tag == "Player") { CanOpen = false; } } @script RequireComponent(AudioSource) Key Script : #pragma strict static var HaveKey : boolean = false; var Doortoopen : GameObject; function Start () { } function Update () { } function OnTriggerStay (Player : Collider){ if(Input.GetKey(KeyCode.E)){ HaveKey = true; Doortoopen.GetComponent(LockedDoor).enabled = true; } } All u have to do is to make an Empty Object then put your door into this Empty Object and add the script , then add the key script to your key and put your door into "DoortoOpen" (var) Leave a like if it helped u
  19. Hello guys, a couple of days ago, I pause my game development since I stacked in the main menu design. So guys I searched for software that can create easily menu for unity, but I didn’t find. So I decide to develop one myself and also to release it! My software is named: Unity 3D – Menu Designer, and have the following features: First of all and in my opinion the most important is the Drag & Drop Function that allows you to design your menu faster and easier! Second is the ability to resize the controls using (A,D,S,W) keys One more and with significant meaning is the Live Debugger* Next one is the ability to export the menu and auto-generate the code in both JavaScript and C Sharp (C#) Create easily buttons, labels, boxes, textboxes, textareas and more and customize them without a single line of code! Finally I also spend quite a lot time to create detailed help menu in order to understand everything and create an amazing menu for your game! I will finish and publish the software within the next week! Stay tuned and please comment bellow [*Live Debugger = you can drag and drop, resize, change the properties of the controls and watch the result at the same time!] //Update i keep working on this , it may take some time since there are a lot of things i need to add. Untill now : Editor : Live Debugger : Updater : ~~ d Version 1 : Beta Not Ready : Screen.Width , Screen.Height functions C# Exporter Labels CAN'T resized by ASDW keys (due to bug) Save / Load Editable Format Download Link : http://www.mediafire.com/download.php?3aywdltg34lj9wu
  20. I want a billiard style of collision that when a lead ball strikes on another ball the lead ball will change the direction of its way
  21. mgudoy

    Meter Bar Problem

    if(increasing){ thePower += Time.deltaTime * barSpeed; thePower = Mathf.Clamp(thePower, 0, fullWidth); guiTexture.transform.localPosition.x = 0.000845 * thePower + 0.125; if(thePower == maxstrength){ thePower -= Time.deltaTime - barSpeed; guiTexture.transform.localPosition.x = 0.125; thePower = Mathf.PingPong(0,fullWidth); } } Here is my code that when increasing the "thePower" will be the force that add when the object thrown it is working but the logic of my bar is when it hits the end or the highest point it will return to 0 the logic goes something like this 0 --- 100 -- 0 I wanted that when it hits the highest point it will decrease if my highest point is 100 the logic goes something like this 100 -- 99 --- 98 until it goes to 0
  22. Can someone help me convert this AI script from CS to JS? I want this script in JS because I don't understand CS. Thanks using UnityEngine; using System.Collections; public class ThirdPersonCharacter : MonoBehaviour { [SerializeField] float jumpPower = 12; // determines the jump force applied when jumping (and therefore the jump height) [SerializeField] float airSpeed = 6; // determines the max speed of the character while airborne [SerializeField] float airControl = 2; // determines the response speed of controlling the character while airborne [Range(1,4)] [SerializeField] public float gravityMultiplier = 2; // gravity modifier - often higher than natural gravity feels right for game characters [SerializeField][Range(0.1f,3f)] float moveSpeedMultiplier = 1; // how much the move speed of the character will be multiplied by [SerializeField][Range(0.1f,3f)] float animSpeedMultiplier = 1; // how much the animation of the character will be multiplied by [SerializeField] AdvancedSettings advancedSettings; // Container for the advanced settings class , thiss allows the advanced settings to be in a foldout in the inspector [System.Serializable] public class AdvancedSettings { public float stationaryTurnSpeed = 180; // additional turn speed added when the player is stationary (added to animation root rotation) public float movingTurnSpeed = 360; // additional turn speed added when the player is moving (added to animation root rotation) public float headLookResponseSpeed = 2; // speed at which head look follows its target public float crouchHeightFactor = 0.6f; // collider height is multiplied by this when crouching public float crouchChangeSpeed = 4; // speed at which capsule changes height when crouching/standing public float autoTurnThresholdAngle = 100; // character auto turns towards camera direction if facing away by more than this angle public float autoTurnSpeed = 2; // speed at which character auto-turns towards cam direction public PhysicMaterial zeroFrictionMaterial; // used when in motion to enable smooth movement public PhysicMaterial highFrictionMaterial; // used when stationary to avoid sliding down slopes public float jumpRepeatDelayTime = 0.25f; // amount of time that must elapse between landing and being able to jump again public float runCycleLegOffset = 0.2f; // animation cycle offset (0-1) used for determining correct leg to jump off public float groundStickyEffect = 5f; // power of 'stick to ground' effect - prevents bumping down slopes. } public Transform lookTarget { get; set; } // The point where the character will be looking at bool onGround; // Is the character on the ground Vector3 lookPos; // The position where the character is looking at float originalHeight; // Used for tracking the original height of the characters capsule collider Animator animator; // The animator for the character float lastAirTime; // USed for checking when the character was last in the air for controlling jumps CapsuleCollider capsule; // The collider for the character const float half = 0.5f; // whats it says, it's a constant for a half Vector3 moveInput; bool crouchInput; bool jumpInput; float turnAmount; float forwardAmount; Vector3 velocity; // Use this for initialization void Start () { animator = GetComponentInChildren<Animator>(); capsule = collider as CapsuleCollider; // as can return null so we need to make sure thats its not before assigning to it if (capsule != null) { originalHeight = capsule.height; capsule.center = Vector3.up * originalHeight * half; } else { Debug.LogError(" collider cannot be cast to CapsuleCollider"); } SetUpAnimator(); } // The Move function is designed to be called from a separate component // based on User input, or an AI control script public void Move (Vector3 move, bool crouch, bool jump, Vector3 lookPos) { // transfer input parameters to member variables. this.moveInput = move; this.crouchInput = crouch; this.jumpInput = jump; this.lookPos = lookPos; // grab current velocity, we will be changing it. velocity = rigidbody.velocity; ConvertMoveInput (); // converts the relative move vector into local turn & fwd values TurnTowardsCameraForward (); // makes the character face the way the camera is looking PreventStandingInLowHeadroom (); // so the character's head doesn't penetrate a low ceiling ScaleCapsuleForCrouching (); // so you can fit under low areas when crouching ApplyExtraTurnRotation(); // this is in addition to root rotation in the animations GroundCheck (); // detect and stick to ground SetFriction (); // use low or high friction values depending on the current state // control and velocity handling is different when grounded and airborne: if (onGround) { HandleGroundedVelocities(); } else { HandleAirborneVelocities(); } UpdateAnimator (); // send input and other state parameters to the animator // reassign velocity, since it will have been modified by the above functions. rigidbody.velocity = velocity; } void ConvertMoveInput () { // convert the world relative moveInput vector into a local-relative // turn amount and forward amount required to head in the desired // direction. Vector3 localMove = transform.InverseTransformDirection (moveInput); turnAmount = Mathf.Atan2 (localMove.x, localMove.z); forwardAmount = localMove.z; } void TurnTowardsCameraForward () { // automatically turn to face camera direction, // when not moving, and beyond the specified angle threshold if (Mathf.Abs (forwardAmount) < .01f) { Vector3 lookDelta = transform.InverseTransformDirection (lookPos - transform.position); float lookAngle = Mathf.Atan2 (lookDelta.x, lookDelta.z) * Mathf.Rad2Deg; // are we beyond the threshold of where need to turn to face the camera? if (Mathf.Abs (lookAngle) > advancedSettings.autoTurnThresholdAngle) { turnAmount += lookAngle * advancedSettings.autoTurnSpeed * .001f; } } } void PreventStandingInLowHeadroom () { // prevent standing up in crouch-only zones if (!crouchInput) { Ray crouchRay = new Ray (rigidbody.position + Vector3.up * capsule.radius * half, Vector3.up); float crouchRayLength = originalHeight - capsule.radius * half; if (Physics.SphereCast (crouchRay, capsule.radius * half, crouchRayLength)) { crouchInput = true; } } } void ScaleCapsuleForCrouching () { // scale the capsule collider according to // if crouching ... if (onGround && crouchInput && (capsule.height != originalHeight * advancedSettings.crouchHeightFactor)) { capsule.height = Mathf.MoveTowards (capsule.height, originalHeight * advancedSettings.crouchHeightFactor, Time.deltaTime * 4); capsule.center = Vector3.MoveTowards (capsule.center, Vector3.up * originalHeight * advancedSettings.crouchHeightFactor * half, Time.deltaTime * 2); } // ... everything else else if (capsule.height != originalHeight && capsule.center != Vector3.up * originalHeight * half) { capsule.height = Mathf.MoveTowards (capsule.height, originalHeight, Time.deltaTime * 4); capsule.center = Vector3.MoveTowards (capsule.center, Vector3.up * originalHeight * half, Time.deltaTime * 2); } } void ApplyExtraTurnRotation () { // help the character turn faster (this is in addition to root rotation in the animation) float turnSpeed = Mathf.Lerp (advancedSettings.stationaryTurnSpeed, advancedSettings.movingTurnSpeed, forwardAmount); transform.Rotate (0, turnAmount * turnSpeed * Time.deltaTime, 0); } void GroundCheck () { Ray ray = new Ray (transform.position + Vector3.up * .1f, -Vector3.up); RaycastHit[] hits = Physics.RaycastAll (ray, .5f); System.Array.Sort (hits, new RayHitComparer ()); if (velocity.y < jumpPower * .5f) { onGround = false; rigidbody.useGravity = true; foreach (var hit in hits) { // check whether we hit a non-trigger collider (and not the character itself) if (!hit.collider.isTrigger) { // this counts as being on ground. // stick to surface - helps character stick to ground - specially when running down slopes if (velocity.y <= 0) { rigidbody.position = Vector3.MoveTowards (rigidbody.position, hit.point, Time.deltaTime * advancedSettings.groundStickyEffect); } onGround = true; rigidbody.useGravity = false; break; } } } // remember when we were last in air, for jump delay if (!onGround) lastAirTime = Time.time; } void SetFriction() { if (onGround) { // set friction to low or high, depending on if we're moving if (moveInput.magnitude == 0) { // when not moving this helps prevent sliding on slopes: collider.material = advancedSettings.highFrictionMaterial; } else { // but when moving, we want no friction: collider.material = advancedSettings.zeroFrictionMaterial; } } else { // while in air, we want no friction against surfaces (walls, ceilings, etc) collider.material = advancedSettings.zeroFrictionMaterial; } } void HandleGroundedVelocities() { velocity.y = 0; if (moveInput.magnitude == 0) { // when not moving this prevents sliding on slopes: velocity.x = 0; velocity.z = 0; } // check whether conditions are right to allow a jump: bool animationGrounded = animator.GetCurrentAnimatorStateInfo (0).IsName ("Grounded"); bool okToRepeatJump = Time.time > lastAirTime + advancedSettings.jumpRepeatDelayTime; if (jumpInput && !crouchInput && okToRepeatJump && animationGrounded) { // jump! onGround = false; velocity = moveInput * airSpeed; velocity.y = jumpPower; } } void HandleAirborneVelocities () { // we allow some movement in air, but it's very different to when on ground // (typically allowing a small change in trajectory) Vector3 airMove = new Vector3 (moveInput.x * airSpeed, velocity.y, moveInput.z * airSpeed); velocity = Vector3.Lerp (velocity, airMove, Time.deltaTime * airControl); rigidbody.useGravity = true; // apply extra gravity from multiplier: Vector3 extraGravityForce = (Physics.gravity * gravityMultiplier) - Physics.gravity; rigidbody.AddForce(extraGravityForce); } void UpdateAnimator () { // Here we tell the animator what to do based on the current states and inputs. // only use root motion when on ground: animator.applyRootMotion = onGround; // update the current head-look position lookPos = Vector3.Lerp (lookPos, lookPos, Time.deltaTime * advancedSettings.headLookResponseSpeed); // update the animator parameters animator.SetFloat ("Forward", forwardAmount, 0.1f, Time.deltaTime); animator.SetFloat ("Turn", turnAmount, 0.1f, Time.deltaTime); animator.SetBool ("Crouch", crouchInput); animator.SetBool ("OnGround", onGround); if (!onGround) { animator.SetFloat ("Jump", velocity.y); } // calculate which leg is behind, so as to leave that leg trailing in the jump animation // (This code is reliant on the specific run cycle offset in our animations, // and assumes one leg passes the other at the normalized clip times of 0.0 and 0.5) float runCycle = Mathf.Repeat (animator.GetCurrentAnimatorStateInfo (0).normalizedTime + advancedSettings.runCycleLegOffset, 1); float jumpLeg = (runCycle < half ? 1 : -1) * forwardAmount; if (onGround) { animator.SetFloat ("JumpLeg", jumpLeg); } // the anim speed multiplier allows the overall speed of walking/running to be tweaked in the inspector, // which affects the movement speed because of the root motion. if (onGround && moveInput.magnitude > 0) { animator.speed = animSpeedMultiplier; } else { // but we don't want to use that while airborne animator.speed = 1; } } void OnAnimatorIK(int layerIndex) { // we set the weight so most of the look-turn is done with the head, not the body. animator.SetLookAtWeight(1, 0.2f, 2.5f); // if a transform is assigned as a look target, it overrides the vector lookPos value if (lookTarget != null) { lookPos = lookTarget.position; } // Used for the head look feature. animator.SetLookAtPosition( lookPos ); } void SetUpAnimator() { // this is a ref to the animator component on the root. animator = GetComponent<Animator>(); // we use avatar from a child animator component if present // (this is to enable easy swapping of the character model as a child node) foreach (var childAnimator in GetComponentsInChildren<Animator>()) { if (childAnimator != animator) { animator.avatar = childAnimator.avatar; Destroy (childAnimator); break; } } } public void OnAnimatorMove() { // we implement this function to override the default root motion. // this allows us to modify the positional speed before it's applied. rigidbody.rotation = animator.rootRotation; if (onGround && Time.deltaTime > 0) { Vector3 v = (animator.deltaPosition * moveSpeedMultiplier) / Time.deltaTime; // we preserve the existing y part of the current velocity. v.y = rigidbody.velocity.y; rigidbody.velocity = v; } } //used for comparing distances class RayHitComparer: IComparer { public int Compare(object x, object y) { return ((RaycastHit)x).distance.CompareTo(((RaycastHit)y).distance); } } }
  23. using UnityEngine; public class PositionCamera : MonoBehaviour { public GUITexture Image; void OnGUI() { AutoResize(800, 480); GUI.DrawTexture(new Rect(0.0f, 0.0f, Image.width, Image.height), Image); } public static void AutoResize(int screenWidth, int screenHeight) { Vector2 resizeRatio = new Vector2((float)Screen.width / screenWidth, (float)Screen.height / screenHeight); GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(resizeRatio.x, resizeRatio.y, 1.0f)); } } I found this code and apply it is good but I want it to be in GUITexture can anyone try to analyze this and help me to do my thing? I want that the GUItexture will resize automatically when the screen is different
  24. using UnityEngine; using System.Collections; public class ZoomInOut : MonoBehaviour { public float distance; private float sensitivityDistance = -7.5f; private float damping = 2.5f; private float min = -15; private float max = -2; private Vector3 zdistance; void Start () { distance = -10f; distance = transform.localPosition.z; } void Update () { distance -= Input.GetAxis("Mouse ScrollWheel") * sensitivityDistance; distance = Mathf.Clamp(distance, min, max); zdistance.z = Mathf.Lerp(transform.localPosition.z, distance, Time.deltaTime * damping); transform.localPosition = zdistance; } }
  25. var fullWidth : float = 100.0; private var thePower = 0; var increasing : boolean = true; private var shooting : boolean = false; var barSpeed : float = 50; var Pamato : Rigidbody; var spawnPos : Transform; var shotForce : float = 10; var powerButton : GUITexture; var Move : GameObject; private var maxstrength : float = 200; function Start(){ guiTexture.pixelInset.width = 0; } function Update () { for (var touch : Touch in Input.touches) { if(touch.phase == TouchPhase.Stationary && powerButton.HitTest(touch.position)){ if (Pamato.velocity.magnitude == 0.00f){ Move.SetActive(true); increasing = true; } else{ increasing = false; } } if(touch.phase == TouchPhase.Ended && powerButton.HitTest){ Move.SetActive(false); increasing = false; Shoot(thePower); rigidbody.isKinematic = false; } } if(increasing){ thePower += Time.deltaTime * barSpeed; thePower = Mathf.Clamp(thePower, 0, fullWidth); guiTexture.pixelInset.width = thePower; if(thePower == maxstrength){ thePower -= Time.deltaTime - barSpeed; thePower = Mathf.PingPong(0,fullWidth); guiTexture.pixelInset.width = 0; } } } function Shoot(power : float){ shooting = true; var fwd : Vector3 = spawnPos.forward; Pamato.AddForce(fwd * power * shotForce); guiTexture.pixelInset.width = 0; thePower = 0; shooting = false; } It is a GUITexture Thanks for some help
×
×
  • Create New...