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



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

Calendars

  • Community Calendar

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 12 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. 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.
  3. http://www.m2h.nl/files/js_to_c.php Hi, Since this is one of my first EVER contributions to ANY forum whatsoever I am offering you something I found that can prove useful to some of you! =) That's the link above..
  4. 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);
  5. 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
  6. Hey guys, I fixed this error around about 3am this morning, but I must of not saved it and can't remember how I fixed it. Can I get a little help please. Code; #pragma strict var size : Vector2 = new Vector2(240, 20); var staminaPos : Vector2 = new Vector2(20,60); var staminaBarDisplay : float = 1; var staminaBarEmpty : Texture2D; var staminaBarFull : Texture2D; var staminaFallRate : int = 35; private var chMotor : CharacterMotor; private var controller : CharacterController; var canJump : boolean = false; var jumpTimer : float = 0.7; function Start () { chMotor = GetComponent(CharacterMotor); controller = GetComponent(CharacterController); } function OnGUI() { GUI.BeginGroup(new Rect(staminaPos.x, staminaPos.y, size.x, size.y)); GUI.Box(Rect(0, 0, size.x, size.y), staminaBarEmpty); GUI.BeginGroup(new Rect(0, 0, size.x * staminaBarDisplay, size.y)); GUI.Box(Rect(0,0, size.x, size.y), staminaBarFull); GUI.EndGroup(); GUI.EndGroup(); } function Update() { //Stamina Control if(ControllerColliderHit.velocity.magnitube > 0 && Input.GetKey(KeyCode.LeftShift)) { chMotor.movement.maxForwardSpeed = 10; chMotor.movement.maxSidewaysSpeed = 10; staminaBarDisplay -= Time.deltaTime / staminaFallRate; } else { chMotor.movement.maxForwardSpeed = 6; chMotor.movement.maxSidewaysSpeed = 6; staminaBarDisplay += Time.deltaTime / staminaFallRate; } //Jumping Control if(Input.GetKeyDown(KeyCode.Space) && canJump == true) { staminaBarDisplay -= 0.2; Wait(); } if(canJump == false) { jumpTimer -= Time.deltaTime; chMotor.jumping.enabled = false; } if(jumpTimer <= 0) { canJump = true; chMotor.jumping.enabled = true; jumpTimer = 0.7; } if(staminaBarDisplay <= 0.2) { canJump = false; chMotor.jumping.enabled = false; } if(staminaBarDisplay >= 1) { staminaBarDisplay = 1; } if(staminaBarDisplay <= 0) { staminaBarDisplay = 0; chMotor.movement.maxForwardSpeed = 6; chMotor.movement.maxSidewaysSpeed = 6; } } function Wait() { yield WaitForSeconds(0.5); canJump = false; } Thank you.
  7. 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); } } }
  8. ogike

    Collisions

    Hi! I want to detect if the player is grounded, there's something above his head and if it's colliding with walls from sides in one script. I have a basic movement script, what detects if the player is standing, but I want it to detect if there's something above his head, so when im crouching, i won't get into objects. How can I get the two collison info seperated? Here's the code that I'm using: function OnCollisionStay (collision : Collision) { for (var contact : ContactPoint in collision.contacts) { if (Vector3.Angle(contact.normal, Vector3.up) < maxSlope) grounded = true; } } function OnCollisionExit () { grounded = false; } Also how can I simply describe the two sides in one for wall-jumping (so (Vector3.Angle((contact.normal,/ Vector3.left AND right/)? Any help would be appreciated.)
  9. So, I was taking a look at the help section when i noticed that a few people needed help making a simple multiplayer system for their game. I decided to make one. This package includes the following: -Directconnect.js -ServerHost(Both masterserver poll list, and custom server options ex: maxplayers n' more) -Chat script (m2h's with a little edit) -Serverhub script -Mini test player prefab -Demo scene -Instruction manuel I hope you enjoy it as much as I enjoyed codin it! http://www.mediafire.com/?ut7c6coch5ik39x Edit: I realized an error, If you created a password for your server, you cannot chat in the game. To fix replace the code in 'Serverhosting.js' with this: #pragma strict var serverPort = 8080; var maxcons = 10; var gamename = ""; var dedicatedboolean = false; var mainservercam : GameObject; var extradetail = ""; var networkpass = ""; var msg = ""; var Server = false; var Client = false; var refreshtime = false; var refresh = 1.5; var maxtime = 1.5; var pings = 0; var playerToInstantiate : Transform; var spawner : GameObject; var playerinputpass = ""; function Awake(){ if(gamename == "" && Server == true){ gamename = " Game:" + Random.Range(1,999); } if(Client == true){ MasterServer.RequestHostList("RegularGame"); } } function OnGUI(){ if(Network.peerType == NetworkPeerType.Disconnected && Server == true){ GUI.Box(Rect((Screen.width)/2-150,100,300,400),"Server options : "); GUI.Label(Rect((Screen.width)/2-140,150,150,50),"Server Port : "); serverPort = parseInt(GUI.TextField(Rect((Screen.width)/2-10,150,150,25),serverPort.ToString())); GUI.Label(Rect((Screen.width)/2-140,180,150,50),"Max Connections : "); maxcons = parseInt(GUI.TextField(Rect((Screen.width)/2-10,180,150,25),maxcons.ToString())); GUI.Label(Rect((Screen.width)/2-140,210,150,50),"Game Name : "); gamename = GUI.TextField(Rect((Screen.width)/2-10,210,150,25),gamename,10); GUI.Label(Rect((Screen.width)/2-140,240,150,50),"Dedicated Server : "); if(GUI.Button(Rect((Screen.width)/2-10,240,70,25),"Yes")){ dedicatedboolean = true; } if(GUI.Button(Rect((Screen.width)/2+70,240,70,25),"No")){ dedicatedboolean = false; } GUI.Label(Rect((Screen.width)/2-140,270,150,50),"Add Password: "); networkpass = GUI.TextField(Rect((Screen.width)/2-10,270,150,25),networkpass,25); GUI.Label(Rect((Screen.width)/2-140,300,200,25),"Additional server comments : "); extradetail = GUI.TextArea(Rect((Screen.width)/2-140,330,280,60),extradetail); if(GUI.Button(Rect((Screen.width)/2-140,400,280,50),"[Start the Server!]")){ MasterServer.dedicatedServer = dedicatedboolean; MasterServer.updateRate = 10; if(networkpass != ""){ Network.incomingPassword = networkpass; } Network.InitializeSecurity(); Network.InitializeServer(maxcons , serverPort); MasterServer.RegisterHost("RegularGame" , gamename , extradetail); } GUI.Label(Rect((Screen.width)/2-140,430,280,25),msg); if(GUI.Button(Rect(10,10,150,50),"Return to main area")){ mainservercam.active = true; //clear all the values serverPort = 8080; maxcons = 10; dedicatedboolean = false; gamename = ""; extradetail = ""; networkpass = ""; this.active = false; } GUI.Label(Rect(Screen.width-150,Screen.height-20,200,25),"Status : Disconnected"); } if(Network.peerType == NetworkPeerType.Client && Client == true){ if(GUI.Button(Rect(10,10,100,25),"Disconnect")){ Network.Disconnect(200); } GUI.Label(Rect(Screen.width-150,Screen.height-20,200,25),"Status : Client"); if(Network.connections.Length > 0){ GUI.Label(Rect(120,10,200,50),"Ping : " + pings + "ms"); } } if(Network.peerType == NetworkPeerType.Server && Server == true){ if(GUI.Button(Rect(10,10,100,50),"Disconnect")){ Network.Disconnect(200); MasterServer.UnregisterHost(); } GUI.Label(Rect(Screen.width-150,Screen.height-20,200,25),"Status : Server"); GUI.Label(Rect(120,10,200,50),"Current Players : " + Network.connections.Length + "/" + maxcons); if(Network.connections.Length > 0){ GUI.Label(Rect(500,10,200,50),"Server Ping: " + pings + "ms"); } } if(Network.peerType == NetworkPeerType.Disconnected && Client == true){ var hostData: HostData[] = MasterServer.PollHostList(); for(var i : int; i<hostData.length; i++){ if(hostData[i].passwordProtected == false){ GUI.Box(Rect((Screen.width)/2-250,10*5+30 * i,500,27),"Game Name :" + hostData[i].gameName +"|Host Info:"+hostData[i].ip[0]+":"+hostData[i].port+ "|Players : " + hostData[i].connectedPlayers + "/" + hostData[i].playerLimit); if(GUI.Button(Rect((Screen.width)/2+250,10*5+30 * i,100,25),"Connect")){ Network.Connect(hostData[i].ip , hostData[i].port); } }else{ GUI.Box(Rect((Screen.width)/2-250,10*5+30 * i,350,25),"Game Name :" + hostData[i].gameName +"|Players : " + hostData[i].connectedPlayers + "/" + hostData[i].playerLimit); playerinputpass = GUI.TextField(Rect((Screen.width)/2+100,10*5+30*i,150,25),playerinputpass,25); if(GUI.Button(Rect((Screen.width)/2+250,10*5+30 * i,100,25),"Connect")){ Network.Connect(hostData[i].ip , hostData[i].port,playerinputpass); } } } GUI.Box(Rect(10,10,280,200),"Master Server List"); if(GUI.Button(Rect(180,30,100,50),"Refresh list")){ MasterServer.ClearHostList(); MasterServer.RequestHostList("RegularGame"); refreshtime = true; } if(refresh < 1){ Debug.Log("Refreshing... Found games : " + MasterServer.PollHostList().Length); } if(GUI.Button(Rect(20,30,150,50),"Return to main area")){ mainservercam.active = true; this.active = false; } GUI.Label(Rect(20,90,250,100),msg); GUI.Label(Rect(Screen.width-150,Screen.height-20,200,25),"Status : Disconnected"); } } function OnFailedToConnect(error: NetworkConnectionError) { msg = "Network error: " + error; } function OnMasterServerEvent(msEvent: MasterServerEvent) { if (msEvent == MasterServerEvent.RegistrationSucceeded) { Debug.Log("Server registered"); } if(msEvent == MasterServerEvent.RegistrationFailedGameType){ Debug.Log("Failed on Game Type"); } if(msEvent == MasterServerEvent.RegistrationFailedNoServer){ Debug.Log("Failed no server"); } if(msEvent == MasterServerEvent.RegistrationFailedGameName){ Debug.Log("Failed No game name"); } } function Update(){ if(Client == true && refreshtime == true){ refresh = refresh - Time.deltaTime; if(refresh < -5.0){ refresh = maxtime; refreshtime = false; } } if(Network.peerType == NetworkPeerType.Server){ if(Network.connections.Length > 0){ pings = Network.GetAveragePing(Network.connections[0]); } } } function OnConnectedToServer(){ if(Network.peerType == NetworkPeerType.Client){ Instantiate(playerToInstantiate , spawner.transform.position , spawner.transform.rotation); } } function OnPlayerConnected(player: NetworkPlayer){ Debug.Log("Player connected"); } function OnPlayerDisconnected(player: NetworkPlayer){ Network.RemoveRPCs(player); Network.DestroyPlayerObjects(player); } function OnServerInitialized(){ if(Network.peerType == NetworkPeerType.Server){ Instantiate(playerToInstantiate , spawner.transform.position, spawner.transform.rotation); } }
  10. Tested On 3.5 Since i refuse to use Unity 4. This is a simple Javascript for "Parkour" Basicly it allows you to climb over obstacles. Like in call of duty "Climb over a fence" It doesnt look good but it works.. I found this lying around on the interwebs so i thought i would share.. http://forum.unity3d.com/threads/159070-Parkour-System var Hand : GameObject; var UpPlataformName = ""; var CanUpPlataform1 = false; var CanUpPlataform2 = false; var CanDoubleJump = false; var Range = 1.5; var canTranform = false; function Update () { var hit : RaycastHit; var Direction = transform.forward; if(Physics.Raycast(transform.position, Direction, hit, Range)){ if(hit.collider.gameObject.tag == "Up1"){ CanUpPlataform1 = true; } if(hit.collider.gameObject.tag == "Up2"){ CanUpPlataform2 = true; } if(hit.collider.gameObject.tag == "Untagged"){ CanDoubleJump = true; } } if(Input.GetKeyDown(KeyCode.Space)&& CanUpPlataform1 == true){ transform.position.y += 2; transform.position.z += 2; audio.Play(); CanUpPlataform1 = false; } if(Input.GetKeyDown(KeyCode.Space)&& CanUpPlataform2 == true){ transform.position.y += 0.7 ; audio.Play(); CanUpPlataform2 = false; } if(Input.GetKeyDown(KeyCode.Space)&& CanDoubleJump == true){ canTranform = true; transform.Rotate(0, 180, 0); if(canTranform == true){ transform.Translate( 0, 5, 0); transform.Translate(0, 0, 10 * Time.deltaTime); } audio.Play(); CanDoubleJump = false; } } function OnCollisionEnter(col : Collision){ canTranform = false; } Hopefully This will be usefull for someone and maybe even customize it. Have fun.
  11. Hi guys , i tried to create a simple AI for my animals in my project and i failed for many reasons, so what i need is : An AI that : Playing an idle animation and walking randomly around playing [("idle") , ("walkAnim")] When the player go near the animal it runs away playing the run animation [("runAnim")] and after getting a safe distance it turns again to previous state. can someone write this for me , C# or JS what ever you like, thanks in advance , and of course you will be added to credits.
  12. function ReloadShotgun (){ animation.Play(startReload); yield WaitForSeconds(0.4); animation.Play(insertBullet); yield WaitForSeconds(0.2); audio.clip = SGinsert; audio.volume = 1.0; audio.Play(); yield WaitForSeconds(0.2); animation.Play(endReload); yield WaitForSeconds(0.2); audio.clip = SGpump; audio.volume = 1.0; audio.Play(); } is there a way to make this do it 8 times. So it will put 8 Sheels in then play "EndReload" animation?
×
×
  • Create New...