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



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 32 results

  1. Hello armedunity forum, I have a short question to the character/player avatar. I have one rigged legacy character with legacy animations, the char & anim's working perfect. But the char doesn't have a fbx, only single mesh. So I'm not able to generate a Avatar, and I can't convert the character to a mecanim character without avatar. I have only the prefab in my scene and the single mesh in my asset folder. So I wan't to make the character playable with mecanim animations. My question is, is there a way to fix this problem? Picture from my rigged character .prefab in the scene: Thanks:)
  2. Hi armedunity forum, I have a short question. I have created a character with many clothings, so first the jeans (in the picture) are perfect rigged with the character, he will follow him perfect. But only the skin looks out of the clothing. My question is, how can I fix that? Picture: Thanks;)
  3. IBrain give you the power to create very easy SMART Character !!With the top drop-down menu, providing options for create a character with types and behaviors like :Chase, Waypoints, Random..The project also includes a range of simple example character form Mecanim Example asset and new Smart Waypoint scriptWork with Mobile and Unity 2017.XX https://www.assetstore.unity3d.com/en/#!/content/116128
  4. Hey there fellas ! How are you all ? Good I hope ! Here is some character I made. It is rigged and has animations. (I wish I had screen recorder to show it with Anims) He looks cool right ? Any critics are welcome Aki Shaqs PS: Do let me know if anyone likes it and wanna check it out. Also Guys, I have set up my portfolio (sort of) click here --> Akishaqs. Tell me if it looks nice, I will be adding more stuff there so... Can you guys just take a look and give some feedback ? Thank you !
  5. Hello folks!, I am creating a 2D online game based on a fantasy and adventure world, the logical part between server and client I am going muto well until now, I have done all the treatments of this type and also implemented the database. But an important thing is the inventory system, where I will equip the character and change his look, but in 3D games this is not difficult but I am finding it difficult to do for a 2D game that are treated as sprites .. I'll need support, if anyone knows where I start, suggestion, idea, anything is welcome. For example: When equipping an armor I know I should by the sprite on top of the other, that's fine, I can activate the sprite but how will I use the correct sprites for the animations of the original sprite, for example, when the player moves left it use the armor sprite on the same side and so on for the other positions. How can I do animations of sprites related to attacks when equipping a sword. In fact it is an equipment system for sprites (2D characters as in RPG Maker games). I have seen this system in other engines but I have never been able to reproduce in unity, if anyone can help me, I am grateful. See you.
  6. Hi! It's been a while. I'm working now on a project, and in the making of the character, I've encountered a rig problem. I've attached the image with the problem. I've tried to use weight painting, but it has no effect, also tried to change de vertex group, but also had no effect. This is how it looks without movement
  7. Hi. I got the FPS Kit c# version, and I'm trying to use it for a mecanim setup (Standard TPS Scene). I transferred The weapon manager to the Hand, also the Sounds and MiniMap, Placed the Weapons Correctly, and Turned off the Arms of the original player after taking out the weapon, also moved all the character scripts and disabled the camera script since I have another camera setup, Also Added The FPS controller to the Weapon Script and Picked the player camera at the same script. The weapon runs, Muzzle flash is showing and bullet counter / Reload are working fine, but it seems like a problem with the Raycast of the hit, it doesn't shoot from the weapon forward and I didn't even find where is it shooting, also the sounds and footsteps aren't working, Health is working fine, the Pick Item "E" GUI shows up but I can't pick the item. I need the whole system Except the movement and animation scripting, and I'm using the same original project folder. I'd like to know what to change, Thanks in Advance. Edit: Just Noticed the Raycast Only shows like this (The Red Line) When I set my back to the wall, when I get off it no longer shows. What's the Problem? Edit #2: The RayCast is for the "Protect Camera From Wall" Script, but somehow the Shooting Still works only on that wall, and seems to come from somewhere far.
  8. Hi guys, The problem, as seen in the picture. Hill should stop. But how? Thank you..
  9. Hello everyone, im self taught 3D artist with years of experience, i have a character model to sell, this is Barbarian 3D model for mobile game, here the details: Price: $40 Model Description: - Rigged and ready for animation - the polycount is low so its suit best for mobile or web based game - the model include two armour and pants (like in the preview image) I give support for fixing some problem for free if needed, and im open for freelance 3d modelling work for any type or style game assets, more artwork can viewed in my portfolio: http://www.artstation.com/artist/amirhm please contact me by email: tiganbebek@gmail.com for quick answer. thank you in advance
  10. I am trying to develop multiplayer games with Unity3D and I use a plugin "MultiLAN V3.0" and I must add the functionality of team and character choose , it is for my study project and I am very a hurry by time, I would be very grateful for your help .
  11. Hello! I have a problem nothing big but don't really know how to fix it. So I have a script that makes you able to add a Custom GUI. The Problem is that it still doesn't change the GUI for some reason. If anyone can fix it would be very appreciated, thanks. import System; import System.Collections; import System.Xml; import System.Xml.Serialization; import System.IO; import System.Text; class DemoData { var x : float; var y : float; var z : float; var name : String; var experience : float; } class UserData { public var _iUser : DemoData = new DemoData(); function UserData() { } } //var target: Transform; //var generalWidth = 50; //var userHeight = 50; //var playerHealth = 1000; //var MaxPlayerHealth = 1000; //var playerMana = 1000; //var playerEnergy = 100; //public var playerDamage = 10; //var playerCurrency = 5000; var playerPositionX = 0; var playerPositionY = 0; var playerPositionZ = 0; //var damageNpc = 1; //Variable For Experience ******************************************************* public static var curExperience = 1; var ExpBarEmtey = 0; var ExpBarCur : float; var screenHeight : float; static var ExpPart = 25; var curLevel = 1; var LvMax = 0; var Lv0 = 1; var Lv1 = 5; var Lv2 = 8; var Lv3 = 9; var Lv4 = 12; var Lv5 = 15; var Lv6 = 17; var Lv7 = 18; var Lv8 = 19; var Lv9 = 20; var Lv10 = 25; var Lv11 = 26; var Lv12 = 28; var Lv13 = 30; var Lv14 = 32; var Lv15 = 33; var Lv16 = 36; var Lv17 = 39; var Lv18 = 42; var Lv19 = 43; var Lv20 = 45; //EndofExpVariables ************************************************************* //Saving Variables ************************************************************** private var _Save : Rect; private var _Load : Rect; private var _SaveMSG : Rect; private var _LoadMSG : Rect; //var _ShouldSave : boolean; //var _ShouldLoad : boolean; //var _SwitchSave : boolean; //var _SwitchLoad : boolean; private var _FileLocation : String; private var _FileName : String = "SaveData.xml"; //public GameObject player; var player : GameObject; var playerName : String = "Default"; var MyStyle : GUISkin; private var myData : UserData; private var _data : String; private var VPosition : Vector3; //EndOfSaving Variables ********************************************************* function Awake () { // GUI for the Save/Load _Save=new Rect(10,33,60,20); _Load=new Rect(10,55,60,20); _Name=new Rect(50,240,200,20); _SaveMSG=new Rect(50,120,200,40); _LoadMSG=new Rect(50,140,200,40); _NameMSG=new Rect(50,180,200,40); // XML Save/Load path _FileLocation=Application.dataPath; // Creating something to store information into. myData=new UserData(); } function OnGUI () { // playerName = GUI.TextArea (Rect(generalWidth,userHeight,100,25),playerName); //Health ******************************************************************** // GUI.Box (Rect (50,75,150,25), "Health:" + playerHealth); //EndOfHealth *************************************************************** //Mana ********************************************************************** // GUI.Box (Rect (50,100,150,25), "Mana:" + playerMana); //EndOfMana ***************************************************************** //Energy ******************************************************************** // GUI.Box (Rect (50,125,150,25), "Energy:" + playerEnergy); //EndOfEnergy *************************************************************** //Currency ****************************************************************** // GUI.Box (Rect (50,150,150,25), "Gold:" + playerCurrency); //EndOfCurrency ************************************************************* //Experience **************************************************************** GUI.Box (Rect (10,10,60,20),"Level:" + curLevel); //EndOfExperience *********************************************************** //LoadingPlayers ************************************************************ if (GUI.Button(_Load,"Load")) { GUI.Label(_LoadMSG,"Loading from: "+_FileLocation); // Load our UserData into myData LoadXML(); if(_data.ToString() != "") { myData = DeserializeObject(_data); VPosition=new Vector3(myData._iUser.x,myData._iUser.y,myData._iUser.z); player.transform.position=VPosition; curExperience = myData._iUser.experience; Debug.Log("Load Successful"); } } //EndOfLoadingPlayers ******************************************************* //SavingPlayers ************************************************************* if (GUI.Button(_Save,"Save")) { GUI.Label(_SaveMSG,"Saving to: "+_FileLocation); //Debug.Log("SaveLoadXML: sanity check:"+ player.transform.position.x); myData._iUser.x = player.transform.position.x; myData._iUser.y = player.transform.position.y; myData._iUser.z = player.transform.position.z; myData._iUser.name = playerName; myData._iUser.experience = curExperience; // Time to creat our XML! _data = SerializeObject(myData); // This is the final resulting XML from the serialization process CreateXML(); Debug.Log(_data); } //EndOfSavingPlayers ********************************************************* } function Update () { // if(playerHealth <= 0) { // print(playerName + " has died..."); // die(); // } // if(playerHealth > MaxPlayerHealth) // { // playerHealth = MaxPlayerHealth; // } // Here is the level decider. If the current exp is higher then the number there then you +1 level. switch(curLevel){ case 0: if(curExperience <= Lv0){ curLevel += 0; } case 1: if(curExperience >= Lv1){ curLevel += 1; LvMax = Lv1; } break; case 2: if(curExperience >= Lv2){ curLevel += 1; LvMax = Lv2; } break; case 3: if(curExperience >= Lv3){ curLevel += 1; LvMax = Lv3; } break; case 4: if(curExperience >= Lv4){ curLevel += 1; LvMax = Lv4; } break; case 5: if(curExperience >= Lv5){ curLevel += 1; LvMax = Lv5; } break; case 6: if(curExperience >= Lv6){ curLevel += 1; LvMax = Lv6; } break; case 7: if(curExperience >= Lv7){ curLevel += 1; LvMax = Lv7; } break; case 8: if(curExperience >= Lv8){ curLevel += 1; LvMax = Lv8; } break; case 9: if(curExperience >= Lv9){ curLevel += 1; LvMax = Lv9; } break; case 10: if(curExperience >= Lv10){ curLevel += 1; LvMax = Lv10; } break; case 11: if(curExperience >= Lv11){ curLevel += 1; LvMax = Lv11; } break; case 12: if(curExperience >= Lv12){ curLevel += 1; LvMax = Lv12; } break; case 12: if(curExperience >= Lv12){ curLevel += 1; LvMax = Lv12; } break; case 13: if(curExperience >= Lv13){ curLevel += 1; LvMax = Lv13; } break; case 14: if(curExperience >= Lv14){ curLevel += 1; LvMax = Lv14; } break; case 15: if(curExperience >= Lv15){ curLevel += 1; LvMax = Lv15; } break; case 16: if(curExperience >= Lv16){ curLevel += 1; LvMax = Lv16; } break; case 17: if(curExperience >= Lv17){ curLevel += 1; LvMax = Lv17; } break; case 18: if(curExperience >= Lv18){ curLevel += 1; LvMax = Lv18; } break; case 19: if(curExperience >= Lv19){ curLevel += 1; LvMax = Lv19; } break; case 20: if(curExperience >= Lv20){ curLevel += 1; LvMax = Lv20; } break; } } //function die() //{ // player.transform.position = Vector3(5,0,5); // A vector 3 teleport // playerHealth = 1000; // playerMana = 1000; // Reseting the vitals or else it will loop the death(HP = 0) // playerEnergy = 100; //} //function OnCollisionEnter( collision : Collision ) { // if(target == null && GameObject.FindGameObjectsWithTag("Enemy")){ // target = GameObject.FindWithTag("Enemy").transform; //} //} //function OnTriggerEnter() //{ // if(target.gameObject.tag == "Enemy") // { // collider.isTrigger = true; // playerHealth -= damageNpc; // Comment this out if you dont wanna take damage. // curExperience += 5; //Exp per interaction with the enemy. // } //} //XML Code ***************************************************************** function UTF8ByteArrayToString(characters : byte[] ) { var encoding : UTF8Encoding = new UTF8Encoding(); var constructedString : String = encoding.GetString(characters); return (constructedString); } function StringToUTF8ByteArray(pXmlString : String) { var encoding : UTF8Encoding = new UTF8Encoding(); var byteArray : byte[] = encoding.GetBytes(pXmlString); return byteArray; } function SerializeObject(pObject : Object) { var XmlizedString : String = null; var memoryStream : MemoryStream = new MemoryStream(); var xs : XmlSerializer = new XmlSerializer(typeof(UserData)); var xmlTextWriter : XmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8); xs.Serialize(xmlTextWriter, pObject); memoryStream = xmlTextWriter.BaseStream; // (MemoryStream) XmlizedString = UTF8ByteArrayToString(memoryStream.ToArray()); return XmlizedString; } function DeserializeObject(pXmlizedString : String) { var xs : XmlSerializer = new XmlSerializer(typeof(UserData)); var memoryStream : MemoryStream = new MemoryStream(StringToUTF8ByteArray(pXmlizedString)); var xmlTextWriter : XmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8); return xs.Deserialize(memoryStream); } function CreateXML() { var writer : StreamWriter; var t : FileInfo = new FileInfo(_FileLocation+"/"+ _FileName); if(!t.Exists) { writer = t.CreateText(); } else { t.Delete(); writer = t.CreateText(); } writer.Write(_data); writer.Close(); Debug.Log("File written"); } function LoadXML() { //StreamReader r = File.OpenText(_FileLocation+"\\"+ _FileName); var r : StreamReader = File.OpenText(_FileLocation+"/"+ _FileName); var _info : String = r.ReadToEnd(); r.Close(); _data=_info; Debug.Log("File Read"); } //EndOfXML Code **************************************************************
  12. Hi guys, Character, moving with the mouse. But, I want to improve it. E.g, Problem ; How do we do this? So, one way?
  13. Here is a free autodesk page where you can generate a free character and customize it!! You only need an autodesk acount. Click here --> charactergenerator.autodesk.com
  14. So this is a new test for my FPS controller that i might use for future projects. I will need you'r guys feedback. Thanks! https://dl.dropboxusercontent.com/u/61522125/Test/Test.html
  15. HI Today I came to bring a pack of 3d models of Battlefield 3 hope you like it Download Link: *link removed*
  16. so i have this code for my character, but the jumping doesnt work. When i press space, the character simply teleports to a higher position void FixedUpdate() { moveDirection = new Vector3 (Input.GetAxis ("Horizontal") / 2, 0, Input.GetAxis ("Vertical")); moveDirection = transform.TransformDirection (moveDirection); moveDirection *= speed * sppedmultiplier; if ((Input.GetAxis ("Vertical") > 0.5f) && running) sppedmultiplier = 2; else sppedmultiplier = 1; if (GetComponent<CharacterController> ().isGrounded) { if (Input.GetButtonDown ("Jump")) moveDirection.y = jumpSpeed; } moveDirection.y -= gravity * Time.deltaTime; GetComponent<CharacterController> ().Move (moveDirection * Time.deltaTime); }
  17. please somoane help me to change character to fps kit 2.0 , i try on this video but not working https://www.youtube.com/watch?v=R4iShtcYBMw my id skype mentolatux, add me plss and help me
  18. Hi everyone after a long time i decided to upload something for you guys .Feel free to use it in your projects. A Male Survivor Made in 3ds max ,Zbrush and photoshop Hope you guys like it. Download Here- http://adf.ly/qqbK0
  19. Hi Guys, I'm working on a new FPS Samurai game built in unity and require a samurai for the enemy. Currently I've been searching different asset marketplaces however the good assets are super high poly counts. I need a rigged samurai that will work with mecanim animations and that is optimised for mobile performance. I've added a link to a picture of the style I'm after, this is one of the models that is too high res/poly count for my mobile project (found on turbosquid.) LINK to turbosquid asset So that you can visualise what I'm talking about in terms of the gameplay, here is a little WIP video of the game so far DROPBOX link to video Paid work, please comment for inbox me to discuss further. Thanks guys, Regards, Tim
  20. Hi guys, I have a little free asset^^ Prototype Character, a little modification of "SpeedBall Player" model of Character Ink (I separe the claw from the head and prepare different game objects with claws in differents positions) The model is rigged for mecanim You can download from my website totally free! Click here to see the asset and some screenshots
  21. I need a 3D model of a female human. I won't go into detail here, but it is based off of a real person, so it needs recognizable facial details. Also, I will need to see some past work of yours. If you need some programming work done, please explain what you need done before working on the model, as I might not be able to do the task you need. I'm not the best programmer, but I can do a lot. Skype: harshicly5 Email: tre.babcock@gmail.com
  22. I need a 3D model of a female human. I won't go into detail here, but it is based off of a real person, so it needs recognizable facial details. Also, I will need to see some past work of yours. If you need some programming work done, please explain what you need done before working on the model, as I might not be able to do the task you need. I'm not the best programmer, but I can do a lot. Skype: harshicly5 Email: tre.babcock@gmail.com
  23. anarko67

    3D Characters

    Hi guys My free contribution : """GIRL1.FBX(TPOSE)"""" + Texture LINK: https://dl.dropboxus...18149/tpose.fbx https://dl.dropboxus...pose.images.zip """MUSCLE MAN.FBX""" + ( Texture ) : LINK : https://dl.dropboxus...9/MUSCLEMAN.zip """"NINJA.FBX"""" + (TEXTURE) LINK : https://dl.dropboxusercontent.com/u/195918149/Ninja.zip """"MagnusGirl.FBX""""" + (TEXTURE) LINK : https://dl.dropboxusercontent.com/u/195918149/MageGirl.zip """GirlNude.FBX""" + (TEXTURE) """GirlNudeWing.FBX""" + (TEXTURE) """GirlArmor.FBX""" + (TEXTURE) """GirlArmorAfro.FBX""" + (TEXTURE) LINK : (315MO) https://www.dropbox.com/s/eb4ka0b49mnfhk7/GirlMulti.zip Comming soon : MODELS : Child 3D models See you later .
  24. Hello everybody, as am not professional so i came here to you for an advice and help. Well i got problem with combinating two scripts ill drop them here... While one script uses animation for idle,walk,run,jump and another one has idleattack and death. Thing that happens while you play character simply wont do the attack animation, but in inspector it is showing its already attacking. Need some help. Thanks for soon answer ThirdPersonController.js // Require a character controller to be attached to the same game object @script RequireComponent(CharacterController) public var idleAnimation : AnimationClip; public var walkAnimation : AnimationClip; public var runAnimation : AnimationClip; public var jumpPoseAnimation : AnimationClip; public var walkMaxAnimationSpeed : float = 0.75; public var trotMaxAnimationSpeed : float = 1.0; public var runMaxAnimationSpeed : float = 1.0; public var jumpAnimationSpeed : float = 1.15; public var landAnimationSpeed : float = 1.0; private var _animation : Animation; enum CharacterState { Idle = 0, Walking = 1, Trotting = 2, Running = 3, Jumping = 4, } private var _characterState : CharacterState; // The speed when walking var walkSpeed = 2.0; // after trotAfterSeconds of walking we trot with trotSpeed var trotSpeed = 4.0; // when pressing "Fire3" button (cmd) we start running var runSpeed = 6.0; var inAirControlAcceleration = 3.0; // How high do we jump when pressing jump and letting go immediately var jumpHeight = 0.5; // The gravity for the character var gravity = 20.0; // The gravity in controlled descent mode var speedSmoothing = 10.0; var rotateSpeed = 500.0; var trotAfterSeconds = 3.0; var canJump = true; private var jumpRepeatTime = 0.05; private var jumpTimeout = 0.15; private var groundedTimeout = 0.25; // The camera doesnt start following the target immediately but waits for a split second to avoid too much waving around. private var lockCameraTimer = 0.0; // The current move direction in x-z private var moveDirection = Vector3.zero; // The current vertical speed private var verticalSpeed = 0.0; // The current x-z move speed private var moveSpeed = 0.0; // The last collision flags returned from controller.Move private var collisionFlags : CollisionFlags; // Are we jumping? (Initiated with jump button and not grounded yet) private var jumping = false; private var jumpingReachedApex = false; // Are we moving backwards (This locks the camera to not do a 180 degree spin) private var movingBack = false; // Is the user pressing any keys? private var isMoving = false; // When did the user start walking (Used for going into trot after a while) private var walkTimeStart = 0.0; // Last time the jump button was clicked down private var lastJumpButtonTime = -10.0; // Last time we performed a jump private var lastJumpTime = -1.0; // the height we jumped from (Used to determine for how long to apply extra jump power after jumping.) private var lastJumpStartHeight = 0.0; private var inAirVelocity = Vector3.zero; private var lastGroundedTime = 0.0; private var isControllable = true; function Awake () { moveDirection = transform.TransformDirection(Vector3.forward); _animation = GetComponent(Animation); if(!_animation) Debug.Log("The character you would like to control doesn't have animations. Moving her might look weird."); /* public var idleAnimation : AnimationClip; public var walkAnimation : AnimationClip; public var runAnimation : AnimationClip; public var jumpPoseAnimation : AnimationClip; */ if(!idleAnimation) { _animation = null; Debug.Log("No idle animation found. Turning off animations."); } if(!walkAnimation) { _animation = null; Debug.Log("No walk animation found. Turning off animations."); } if(!runAnimation) { _animation = null; Debug.Log("No run animation found. Turning off animations."); } if(!jumpPoseAnimation && canJump) { _animation = null; Debug.Log("No jump animation found and the character has canJump enabled. Turning off animations."); } } function UpdateSmoothedMovementDirection () { var cameraTransform = Camera.main.transform; var grounded = IsGrounded(); // Forward vector relative to the camera along the x-z plane var forward = cameraTransform.TransformDirection(Vector3.forward); forward.y = 0; forward = forward.normalized; // Right vector relative to the camera // Always orthogonal to the forward vector var right = Vector3(forward.z, 0, -forward.x); var v = Input.GetAxisRaw("Vertical"); var h = Input.GetAxisRaw("Horizontal"); // Are we moving backwards or looking backwards if (v < -0.2) movingBack = true; else movingBack = false; var wasMoving = isMoving; isMoving = Mathf.Abs (h) > 0.1 || Mathf.Abs (v) > 0.1; // Target direction relative to the camera var targetDirection = h * right + v * forward; // Grounded controls if (grounded) { // Lock camera for short period when transitioning moving & standing still lockCameraTimer += Time.deltaTime; if (isMoving != wasMoving) lockCameraTimer = 0.0; // We store speed and direction seperately, // so that when the character stands still we still have a valid forward direction // moveDirection is always normalized, and we only update it if there is user input. if (targetDirection != Vector3.zero) { // If we are really slow, just snap to the target direction if (moveSpeed < walkSpeed * 0.9 && grounded) { moveDirection = targetDirection.normalized; } // Otherwise smoothly turn towards it else { moveDirection = Vector3.RotateTowards(moveDirection, targetDirection, rotateSpeed * Mathf.Deg2Rad * Time.deltaTime, 1000); moveDirection = moveDirection.normalized; } } // Smooth the speed based on the current target direction var curSmooth = speedSmoothing * Time.deltaTime; // Choose target speed //* We want to support analog input but make sure you cant walk faster diagonally than just forward or sideways var targetSpeed = Mathf.Min(targetDirection.magnitude, 1.0); _characterState = CharacterState.Idle; // Pick speed modifier if (Input.GetKey (KeyCode.LeftShift) | Input.GetKey (KeyCode.RightShift)) { targetSpeed *= runSpeed; _characterState = CharacterState.Running; } else if (Time.time - trotAfterSeconds > walkTimeStart) { targetSpeed *= trotSpeed; _characterState = CharacterState.Trotting; } else { targetSpeed *= walkSpeed; _characterState = CharacterState.Walking; } moveSpeed = Mathf.Lerp(moveSpeed, targetSpeed, curSmooth); // Reset walk time start when we slow down if (moveSpeed < walkSpeed * 0.3) walkTimeStart = Time.time; } // In air controls else { // Lock camera while in air if (jumping) lockCameraTimer = 0.0; if (isMoving) inAirVelocity += targetDirection.normalized * Time.deltaTime * inAirControlAcceleration; } } function ApplyJumping () { // Prevent jumping too fast after each other if (lastJumpTime + jumpRepeatTime > Time.time) return; if (IsGrounded()) { // Jump // - Only when pressing the button down // - With a timeout so you can press the button slightly before landing if (canJump && Time.time < lastJumpButtonTime + jumpTimeout) { verticalSpeed = CalculateJumpVerticalSpeed (jumpHeight); SendMessage("DidJump", SendMessageOptions.DontRequireReceiver); } } } function ApplyGravity () { if (isControllable) // don't move player at all if not controllable. { // Apply gravity var jumpButton = Input.GetButton("Jump"); // When we reach the apex of the jump we send out a message if (jumping && !jumpingReachedApex && verticalSpeed <= 0.0) { jumpingReachedApex = true; SendMessage("DidJumpReachApex", SendMessageOptions.DontRequireReceiver); } if (IsGrounded ()) verticalSpeed = 0.0; else verticalSpeed -= gravity * Time.deltaTime; } } function CalculateJumpVerticalSpeed (targetJumpHeight : float) { // From the jump height and gravity we deduce the upwards speed // for the character to reach at the apex. return Mathf.Sqrt(2 * targetJumpHeight * gravity); } function DidJump () { jumping = true; jumpingReachedApex = false; lastJumpTime = Time.time; lastJumpStartHeight = transform.position.y; lastJumpButtonTime = -10; _characterState = CharacterState.Jumping; } function Update() { if (!isControllable) { // kill all inputs if not controllable. Input.ResetInputAxes(); } if (Input.GetButtonDown ("Jump")) { lastJumpButtonTime = Time.time; } UpdateSmoothedMovementDirection(); // Apply gravity // - extra power jump modifies gravity // - controlledDescent mode modifies gravity ApplyGravity (); // Apply jumping logic ApplyJumping (); // Calculate actual motion var movement = moveDirection * moveSpeed + Vector3 (0, verticalSpeed, 0) + inAirVelocity; movement *= Time.deltaTime; // Move the controller var controller : CharacterController = GetComponent(CharacterController); collisionFlags = controller.Move(movement); // ANIMATION sector if(_animation) { if(_characterState == CharacterState.Jumping) { if(!jumpingReachedApex) { _animation[jumpPoseAnimation.name].speed = jumpAnimationSpeed; _animation[jumpPoseAnimation.name].wrapMode = WrapMode.ClampForever; _animation.CrossFade(jumpPoseAnimation.name); } else { _animation[jumpPoseAnimation.name].speed = -landAnimationSpeed; _animation[jumpPoseAnimation.name].wrapMode = WrapMode.ClampForever; _animation.CrossFade(jumpPoseAnimation.name); } } else { if(controller.velocity.sqrMagnitude < 0.1) { _animation.CrossFade(idleAnimation.name); } else { if(_characterState == CharacterState.Running) { _animation[runAnimation.name].speed = Mathf.Clamp(controller.velocity.magnitude, 0.0, runMaxAnimationSpeed); _animation.CrossFade(runAnimation.name); } else if(_characterState == CharacterState.Trotting) { _animation[walkAnimation.name].speed = Mathf.Clamp(controller.velocity.magnitude, 0.0, trotMaxAnimationSpeed); _animation.CrossFade(walkAnimation.name); } else if(_characterState == CharacterState.Walking) { _animation[walkAnimation.name].speed = Mathf.Clamp(controller.velocity.magnitude, 0.0, walkMaxAnimationSpeed); _animation.CrossFade(walkAnimation.name); } } } } // ANIMATION sector // Set rotation to the move direction if (IsGrounded()) { transform.rotation = Quaternion.LookRotation(moveDirection); } else { var xzMove = movement; xzMove.y = 0; if (xzMove.sqrMagnitude > 0.001) { transform.rotation = Quaternion.LookRotation(xzMove); } } // We are in jump mode but just became grounded if (IsGrounded()) { lastGroundedTime = Time.time; inAirVelocity = Vector3.zero; if (jumping) { jumping = false; SendMessage("DidLand", SendMessageOptions.DontRequireReceiver); } } } function OnControllerColliderHit (hit : ControllerColliderHit ) { // Debug.DrawRay(hit.point, hit.normal); if (hit.moveDirection.y > 0.01) return; } function GetSpeed () { return moveSpeed; } function IsJumping () { return jumping; } function IsGrounded () { return (collisionFlags & CollisionFlags.CollidedBelow) != 0; } function GetDirection () { return moveDirection; } function IsMovingBackwards () { return movingBack; } function GetLockCameraTimer () { return lockCameraTimer; } function IsMoving () : boolean { return Mathf.Abs(Input.GetAxisRaw("Vertical")) + Mathf.Abs(Input.GetAxisRaw("Horizontal")) > 0.5; } function HasJumpReachedApex () { return jumpingReachedApex; } function IsGroundedWithTimeout () { return lastGroundedTime + groundedTimeout > Time.time; } function Reset () { gameObject.tag = "Player"; } And here the script that is actually supposed to attack using UnityEngine; using System.Collections; public class freeflyprerobeny : MonoBehaviour { //the camera to sync with public Transform imitate; //the physical body of player public Transform playertarget; //animations public AnimationClip run; public AnimationClip idleattack; public AnimationClip death; public AnimationClip attackanim; //states public bool die; private bool deathanim=true; public bool charge; public bool attack; public bool idle; private float timer; public bool enableattackdam=true; public int damage=35; //the 3 target positions to raycast to for attack range public Transform attackrange; public Transform attackrange2; public Transform attackrange3; public bool attackenable=true; private bool dead; private float respawntimer; private int displaytime; //get a refrence of what units are on ur team rather than making a new list public Transform unitlistrefrence; //audio public AudioClip swing; public AudioClip hitt; public AudioClip footsteps; // Use this for initialization void Start () { respawntimer=21; displaytime=20; } // Update is called once per frame void Update () { //get health health die=(health)GetComponent("health"); //dead state if(die){ if(die.dead){ charge=false; idle=false; attack=false; dead=true; //stuff=gameObject.GetComponent("MouseTimeLook"); if(death){ if(deathanim){ animation[death.name].speed = animation[death.name].length / 2f; animation.Play( death.name); deathanim=false; } } } else{ RaycastHit hit = new RaycastHit(); //run animation if(run){ if(charge){ animation[run.name].speed = animation[run.name].length / 0.8f; animation.CrossFade( run.name, 0.12f); } } //idle animation if(idleattack){ if(idle){ animation[idleattack.name].speed = animation[idleattack.name].length / 2f; animation.CrossFade( idleattack.name, 0.25f); } } //attack animation if(attackanim){ if(attack){ animation[attackanim.name].speed = animation[attackanim.name].length / 1f; animation.CrossFade( attackanim.name, 0.15f); } } if(timer>1f){ attack=false; timer=0; } //draw lines to attack range points if(playertarget&attackrange&attackrange2&attackrange3){ Debug.DrawLine(playertarget.transform.position, attackrange.transform.position, Color.red); Debug.DrawLine(playertarget.transform.position, attackrange2.transform.position, Color.red); Debug.DrawLine(playertarget.transform.position, attackrange3.transform.position, Color.red); } //ATTACK if(attack){ if(timer>0.5&timer<0.68){ if(enableattackdam){ if(playertarget&attackrange&attackrange2&attackrange3){ if(Physics.Linecast(playertarget.transform.position, attackrange.transform.position, out hit)|Physics.Linecast(playertarget.transform.position, attackrange2.transform.position, out hit)|Physics.Linecast(playertarget.transform.position, attackrange3.transform.position, out hit)){ if(hit.transform){ audio.clip=hitt; audio.Play(); health dam=(health)hit.transform.GetComponent("health"); if(dam){ team team=(team)hit.transform.GetComponent("team"); team pteam=(team)GetComponent("team"); if(team.teamnumber==pteam.teamnumber){} else dam.currenthealth=dam.currenthealth-damage; } } } } enableattackdam=false; } } timer+=Time.deltaTime; if(timer<0.3f){ //play audio swing audio.clip=swing; audio.Play(); } idle=false; charge=false; } else{ if(charge){ idle=false; } else{ idle=true; } } //charge=true if any of these buttons r being pressed if(Input.GetKey(KeyCode.A)|Input.GetKey(KeyCode.W)|Input.GetKey(KeyCode.S)|Input.GetKey(KeyCode.D)){ if(attack){} else charge=true; } else charge=false; //attack input if(attackenable){ if(Input.GetKeyUp(KeyCode.Mouse0)){ enableattackdam=true; attack=true; } } } if(dead){ respawntimer-=Time.deltaTime; if(displaytime>respawntimer)displaytime=displaytime-1; if(respawntimer<=0){ dead=false; displaytime=20; respawntimer=21; } } } } void OnGUI(){ //message to the player if he is dead if(dead){ GUI.Box(new Rect(200, 300, 190, 50), "You died..Respawn in.. "+displaytime); } //raycast for close units and shopping RaycastHit hit = new RaycastHit(); if(playertarget&attackrange){ if(Physics.Linecast(playertarget.transform.position, attackrange.transform.position, out hit)){ shop shop=(shop)hit.transform.GetComponent("shop"); orderai ai=(orderai)hit.transform.GetComponent("orderai"); if(ai){ if(ai.enableaiorder){} else{ GUI.Box(new Rect(200, 300, 150, 50), "Press E To Give Orders!"); if(Input.GetKey(KeyCode.E)) ai.enableaiorder=true; } } if(shop){ if(shop.menuactive){} else{ GUI.Box(new Rect(200, 300, 150, 50), "Press E To Shop!"); if(Input.GetKey(KeyCode.E)) shop.menuactive=true; } } } } } }
×
×
  • Create New...