pagona
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
March 02, 2015, 05:46:55 PM Last edit: March 02, 2015, 06:29:20 PM by pagona |
|
shit man, i tought you are dead ![Grin](https://bitcointalk.org/Smileys/default/grin.gif) i tried a game, I LOVE IT, i like those real looking soldiers i am fighting against and those units who come near crashed ufo, they fucked me up, nice weapons, ak47, m16, m72, love them all
|
life is amazing
|
|
|
souljah1h
Legendary
Offline
Activity: 1092
Merit: 1000
Hyperspace snail
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
March 02, 2015, 06:55:07 PM |
|
Hi there ! Here is here some good news:From Bter:We have decided to rebuild BTER's backend, completely solve the wallets security issue and re-enable all the tradings. Source: https://twitter.com/btercomAbout Coin2 and exchanges: I'm sharing oldangrey's point of view. There is no emergency to be listed on other places, but we have to think about it. For your information, Coin2 is listed on the Cryptsy vote list and I made about 60 votes with my Cryptsy points and with 0.01 BTC : https://www.cryptsy.com/coinvotes/From me:I'm still alive. I have a few time only because of my 1 year old baby, but I'm following Coin2 here and there (inside the Dev Team). I don't know exactly what I will be able to do for the FPS dev, but I started to learn Unity with the available video tutorials. I bought a Realistic FPS prefab to get a part of the work done. I just have to upload it to make available for other developers. You can test this prefab here: https://dl.dropboxusercontent.com/u/154513922/WebPlayer.htmlUnity is really a good game engine and I found many FPS running with it. You will see some examples in this Top 10 video: https://www.youtube.com/watch?v=2An4m8FnGdsI bought an interesting map for the FPS too, an Hydro Power Station but it will require some work to improve it, specially the trees. https://www.dropbox.com/s/2i4rj7lpuu9p116/Capture%20d%27%C3%A9cran%202015-02-19%2019.08.58.png?dl=0Your prefab runs ALOT and i mean ALOT better than the C2 Demo in terms of smoothness
|
_@/'
|
|
|
nrigo
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
March 02, 2015, 08:42:10 PM |
|
Your prefab runs ALOT and i mean ALOT better than the C2 Demo in terms of smoothness
Thank you for your feedback. The C2 Demo is using an older prefab and it may explain the difference. I like to play with this new prefab demo and I hope we will use it soon ![Smiley](https://bitcointalk.org/Smileys/default/smiley.gif)
|
|
|
|
souljah1h
Legendary
Offline
Activity: 1092
Merit: 1000
Hyperspace snail
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
March 02, 2015, 10:30:43 PM |
|
Your prefab runs ALOT and i mean ALOT better than the C2 Demo in terms of smoothness
Thank you for your feedback. The C2 Demo is using an older prefab and it may explain the difference. I like to play with this new prefab demo and I hope we will use it soon ![Smiley](https://bitcointalk.org/Smileys/default/smiley.gif) Yeah updating the prefab would be a good idea!
|
_@/'
|
|
|
KingArbinV
Legendary
Offline
Activity: 1078
Merit: 1000
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
March 03, 2015, 07:19:24 AM |
|
Your prefab runs ALOT and i mean ALOT better than the C2 Demo in terms of smoothness
Thank you for your feedback. The C2 Demo is using an older prefab and it may explain the difference. I like to play with this new prefab demo and I hope we will use it soon ![Smiley](https://bitcointalk.org/Smileys/default/smiley.gif) Yeah updating the prefab would be a good idea! Who wants to help me?? lol I'll update to the new prefab soon but for now im stuck on this:: using UnityEngine; using System.Collections; using System.Collections.Generic;
public class RigidController2 : MonoBehaviour { /** * Script written by OMA [FPSPrefab1.3] **/ public bool isRemotePlayer = true; public float proneSpeed = 1.0f; public float crouchSpeed = 2.0f; public float walkSpeed = 8.0f; public float runSpeed = 20.0f; public float runSkillLevel = 0.0f; public float gravitySkillLevel = 0.0f;
public int fallDamageMultiplier = 2; GameObject fallAnimGO; public float inAirControl = 0.1f; public float gravity = 20.0f; public float maxVelocityChange = 10.0f; public bool canJump = true; public float jumpHeight = 2.0f; AudioClip fallSound; GameObject playerWeapons; //@HideInInspector public bool grounded = false; private bool sliding = false; private float speed = 10.0f; private bool limitDiagonalSpeed = true; private float normalHeight = 0.5f; private float crouchHeight = -0.2f; private float crouchingHeight = 0.3f; public float proneHeight = -0.7f; private RaycastHit hit; private Transform myTransform; private float rayDistance; private GameObject mainCameraGO; private GameObject weaponCameraGO; int state = 0; float moveSpeed = 2.0f; Vector3 targetVelocity = Vector3.zero; bool onLadder = false; float climbSpeed = 10.0f; bool canClimb = false;
//[RequireComponent(Rigidbody, CapsuleCollider)]
void Awake (){ rigidbody.freezeRotation = true; rigidbody.useGravity = false; myTransform = transform; mainCameraGO = GameObject.FindWithTag("MainCamera"); weaponCameraGO = GameObject.FindWithTag("WeaponCamera"); rayDistance = collider.height * .5 + collider.radius; playerWeapons.animation.wrapMode = WrapMode.Loop; } void FixedUpdate (){ if(isRemotePlayer)return; double inputX = Input.GetAxis("Horizontal"); double inputY = Input.GetAxis("Vertical"); double inputModifyFactor = (inputX != 0.0f && inputY != 0.0f && limitDiagonalSpeed)? .7071 : 1.0f;
if (grounded){ if(state == 0) { if ( Physics.Raycast(myTransform.position, -Vector3.up, hit, rayDistance)) { if (Vector3.Angle(hit.normal, Vector3.up) > 30) { sliding = true; rigidbody.AddRelativeForce (-Vector3.up * 500); } else { sliding = false; } } } // Calculate how fast we should be moving targetVelocity = new Vector3(inputX * inputModifyFactor, 0.0f, inputY * inputModifyFactor); targetVelocity = myTransform.TransformDirection(targetVelocity); targetVelocity *= speed;
// Apply a force that attempts to reach our target velocity Vector3 velocity = rigidbody.velocity; Vector3 velocityChange = (targetVelocity - velocity); velocityChange.x = Mathf.Clamp(velocityChange.x, -maxVelocityChange, maxVelocityChange); velocityChange.z = Mathf.Clamp(velocityChange.z, -maxVelocityChange, maxVelocityChange); velocityChange.y = 0.0f; rigidbody.AddForce(velocityChange, ForceMode.VelocityChange);
if (canJump && Input.GetButtonDown("Jump") && state == 0){ rigidbody.velocity = Vector3(velocity.x, CalculateJumpVerticalSpeed(), velocity.z); } if(Input.GetButton("Use") && onLadder){ canClimb = true; rigidbody.velocity = Vector3(velocity.x, CalculateJumpVerticalSpeed(), velocity.z); } if(state == 0){ if (grounded && Input.GetButton("Run") && Input.GetKey("w")){ speed = runSpeed + runSkillLevel; }else{ speed = walkSpeed; } }else if(state == 1){ speed = crouchSpeed; }else if(state == 2){ speed = proneSpeed; } }else{ if(onLadder && canClimb){ //if(Input.GetAxis("Vertical")){ targetVelocity = new Vector3(0.0f, Input.GetAxis("Vertical") * inputModifyFactor, 0.0f ); targetVelocity *= climbSpeed; targetVelocity = myTransform.TransformDirection(targetVelocity); Vector3 velChange = (targetVelocity - rigidbody.velocity); velChange.x = Mathf.Clamp(velChange.x, -maxVelocityChange, maxVelocityChange); velChange.y = Mathf.Clamp(velChange.y, -maxVelocityChange, maxVelocityChange); velChange.z = 0.0f; rigidbody.AddForce(velChange, ForceMode.VelocityChange); //} /* // Calculate how fast we should be moving targetVelocity = new Vector3(inputX * inputModifyFactor, inputY * inputModifyFactor, 0.0f); targetVelocity = myTransform.TransformDirection(targetVelocity); targetVelocity *= climbSpeed; // Apply a force that attempts to reach our target velocity FIXME_VAR_TYPE velChange= (targetVelocity - rigidbody.velocity); velChange.x = Mathf.Clamp(velChange.x, -maxVelocityChange, maxVelocityChange); velChange.y = Mathf.Clamp(velChange.y, -maxVelocityChange, maxVelocityChange); velChange.z = 0.0f; rigidbody.AddForce(velChange, ForceMode.VelocityChange); */ }else{ // AirControl targetVelocity = new Vector3(Input.GetAxis("Horizontal"), 0.0f, Input.GetAxis("Vertical")); targetVelocity = transform.TransformDirection(targetVelocity) * inAirControl; rigidbody.AddForce(targetVelocity, ForceMode.VelocityChange); } } if(onLadder == false){ canClimb = false; } if(canClimb == false){ // Gravity rigidbody.AddForce(Vector3 (0, (-gravity + gravitySkillLevel) * rigidbody.mass, 0)); } grounded = false; onLadder = false; } void OnCollisionStay ( Collision col ){ foreach(ContactPoint contact in col.contacts){ if(Vector3.Angle(contact.normal, Vector3.up) < 45){ grounded = true; } } } void OnTriggerStay ( Collider other ){ if (other.gameObject.tag == "Ladder") { onLadder = true; grounded = false; } } void HitJumpPad ( float velocity ){ rigidbody.velocity.z += velocity; } void OnCollisionEnter ( Collision collision ){ if(grounded == false){ fallAnimGO.animation.CrossFadeQueued("Fall", 0.3f, QueueMode.PlayNow); float currSpeed = collision.relativeVelocity.magnitude; if (currSpeed > 25) { float damage = currSpeed * fallDamageMultiplier; Debug.Log ("FallDamage" + damage); SendMessage ("PlayerDamage", damage, SendMessageOptions.DontRequireReceiver); } } } void CalculateJumpVerticalSpeed (){ return Mathf.Sqrt(2 * jumpHeight * gravity); } void Update (){ if(isRemotePlayer)return; if(grounded){ if ( rigidbody.velocity.magnitude < (walkSpeed+2) && rigidbody.velocity.magnitude > (walkSpeed-2) && !Input.GetButton("Fire2")){ playerWeapons.animation.CrossFade("Walk"); }else if (rigidbody.velocity.magnitude > (runSpeed -2)){ playerWeapons.animation.CrossFade("Run"); }else if (rigidbody.velocity.magnitude < (crouchSpeed+1) && rigidbody.velocity.magnitude > (crouchSpeed-1) && Input.GetButton("Fire2")){ playerWeapons.animation.CrossFade("CrouchAim"); }else{ playerWeapons.animation.CrossFade("IdleAnim"); } }else{ playerWeapons.animation.CrossFade("IdleAnim"); } if(mainCameraGO.transform.localPosition.y > normalHeight){ mainCameraGO.transform.localPosition.y = normalHeight; } else if(mainCameraGO.transform.localPosition.y < proneHeight){ mainCameraGO.transform.localPosition.y = proneHeight; } weaponCameraGO.transform.localPosition.y = mainCameraGO.transform.localPosition.y; if (Input.GetButtonDown("Crouch")) { if(state == 0 || state == 2){ state = 1; } else if(state == 1){ state = 0; } } if(state == 0){ //Stand Position collider.direction = 1; collider.height = 2.0f; collider.center = Vector3 (0, 0, 0); if(mainCameraGO.transform.localPosition.y < normalHeight){ mainCameraGO.transform.localPosition.y += Time.deltaTime * moveSpeed; } }else if(state == 1){ //Crouch Position collider.direction = 1; collider.height = 1.5f; collider.center = Vector3 (0, -0.25f, 0); if(mainCameraGO.transform.localPosition.y > crouchHeight){ if(mainCameraGO.transform.localPosition.y - (crouchingHeight * Time.deltaTime/.1) < crouchHeight){ mainCameraGO.transform.localPosition.y = crouchHeight; } else { mainCameraGO.transform.localPosition.y -= crouchingHeight * Time.deltaTime/.1; } } if(mainCameraGO.transform.localPosition.y < crouchHeight) { if(mainCameraGO.transform.localPosition.y - (crouchingHeight * Time.deltaTime/.1) > crouchHeight) { mainCameraGO.transform.localPosition.y = crouchHeight; } else { mainCameraGO.transform.localPosition.y += crouchingHeight * Time.deltaTime/.1; } } if (Input.GetButtonDown("Jump")){ state = 0; } } else if(state == 2){ //Prone Position collider.direction = 2; collider.height = 0.5f; collider.center = Vector3 (0, -0.5f, 0); if(mainCameraGO.transform.localPosition.y > proneHeight){ mainCameraGO.transform.localPosition.y += proneHeight * Time.deltaTime * (moveSpeed + rigidbody.velocity.magnitude); } if (Input.GetButtonDown("Jump")){ state = 1; } } if (Input.GetButtonDown("GoProne")){ if(state == 0 || state == 1){ state = 2; } else if(state == 2){ state = 0; } } } void Accelerate ( float accelerateY , float accelerateZ ){ grounded = false; rigidbody.AddRelativeForce (0, accelerateY, accelerateZ); } void OnGUI (){ if(onLadder && !canClimb) GUI.Label( new Rect(Screen.width - (Screen.width/1.7f),Screen.height - (Screen.height/1.4f),800,100),"Press key >>E<< to Climb"); } } Converting it to C# to use it with the new network stuff.. its the last piece of the puzzle lol
|
World without fiats!
|
|
|
souljah1h
Legendary
Offline
Activity: 1092
Merit: 1000
Hyperspace snail
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
March 03, 2015, 12:19:54 PM |
|
Just bought some extra, cheap on polo ![Wink](https://bitcointalk.org/Smileys/default/wink.gif)
|
_@/'
|
|
|
UdjinM6
Legendary
Offline
Activity: 1318
Merit: 1040
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
March 03, 2015, 12:32:17 PM Last edit: March 03, 2015, 04:50:21 PM by UdjinM6 |
|
Your prefab runs ALOT and i mean ALOT better than the C2 Demo in terms of smoothness
Thank you for your feedback. The C2 Demo is using an older prefab and it may explain the difference. I like to play with this new prefab demo and I hope we will use it soon ![Smiley](https://bitcointalk.org/Smileys/default/smiley.gif) Yeah updating the prefab would be a good idea! Who wants to help me?? lol I'll update to the new prefab soon but for now im stuck on this:: using UnityEngine; using System.Collections; using System.Collections.Generic;
public class RigidController2 : MonoBehaviour { /** * Script written by OMA [FPSPrefab1.3] **/ public bool isRemotePlayer = true; public float proneSpeed = 1.0f; public float crouchSpeed = 2.0f; public float walkSpeed = 8.0f; public float runSpeed = 20.0f; public float runSkillLevel = 0.0f; public float gravitySkillLevel = 0.0f;
public int fallDamageMultiplier = 2; GameObject fallAnimGO; public float inAirControl = 0.1f; public float gravity = 20.0f; public float maxVelocityChange = 10.0f; public bool canJump = true; public float jumpHeight = 2.0f; AudioClip fallSound; GameObject playerWeapons; //@HideInInspector public bool grounded = false; private bool sliding = false; private float speed = 10.0f; private bool limitDiagonalSpeed = true; private float normalHeight = 0.5f; private float crouchHeight = -0.2f; private float crouchingHeight = 0.3f; public float proneHeight = -0.7f; private RaycastHit hit; private Transform myTransform; private float rayDistance; private GameObject mainCameraGO; private GameObject weaponCameraGO; int state = 0; float moveSpeed = 2.0f; Vector3 targetVelocity = Vector3.zero; bool onLadder = false; float climbSpeed = 10.0f; bool canClimb = false;
//[RequireComponent(Rigidbody, CapsuleCollider)]
void Awake (){ rigidbody.freezeRotation = true; rigidbody.useGravity = false; myTransform = transform; mainCameraGO = GameObject.FindWithTag("MainCamera"); weaponCameraGO = GameObject.FindWithTag("WeaponCamera"); rayDistance = collider.height * .5 + collider.radius; playerWeapons.animation.wrapMode = WrapMode.Loop; } void FixedUpdate (){ if(isRemotePlayer)return; double inputX = Input.GetAxis("Horizontal"); double inputY = Input.GetAxis("Vertical"); double inputModifyFactor = (inputX != 0.0f && inputY != 0.0f && limitDiagonalSpeed)? .7071 : 1.0f;
if (grounded){ if(state == 0) { if ( Physics.Raycast(myTransform.position, -Vector3.up, hit, rayDistance)) { if (Vector3.Angle(hit.normal, Vector3.up) > 30) { sliding = true; rigidbody.AddRelativeForce (-Vector3.up * 500); } else { sliding = false; } } } // Calculate how fast we should be moving targetVelocity = new Vector3(inputX * inputModifyFactor, 0.0f, inputY * inputModifyFactor); targetVelocity = myTransform.TransformDirection(targetVelocity); targetVelocity *= speed;
// Apply a force that attempts to reach our target velocity Vector3 velocity = rigidbody.velocity; Vector3 velocityChange = (targetVelocity - velocity); velocityChange.x = Mathf.Clamp(velocityChange.x, -maxVelocityChange, maxVelocityChange); velocityChange.z = Mathf.Clamp(velocityChange.z, -maxVelocityChange, maxVelocityChange); velocityChange.y = 0.0f; rigidbody.AddForce(velocityChange, ForceMode.VelocityChange);
if (canJump && Input.GetButtonDown("Jump") && state == 0){ rigidbody.velocity = Vector3(velocity.x, CalculateJumpVerticalSpeed(), velocity.z); } if(Input.GetButton("Use") && onLadder){ canClimb = true; rigidbody.velocity = Vector3(velocity.x, CalculateJumpVerticalSpeed(), velocity.z); } if(state == 0){ if (grounded && Input.GetButton("Run") && Input.GetKey("w")){ speed = runSpeed + runSkillLevel; }else{ speed = walkSpeed; } }else if(state == 1){ speed = crouchSpeed; }else if(state == 2){ speed = proneSpeed; } }else{ if(onLadder && canClimb){ //if(Input.GetAxis("Vertical")){ targetVelocity = new Vector3(0.0f, Input.GetAxis("Vertical") * inputModifyFactor, 0.0f ); targetVelocity *= climbSpeed; targetVelocity = myTransform.TransformDirection(targetVelocity); Vector3 velChange = (targetVelocity - rigidbody.velocity); velChange.x = Mathf.Clamp(velChange.x, -maxVelocityChange, maxVelocityChange); velChange.y = Mathf.Clamp(velChange.y, -maxVelocityChange, maxVelocityChange); velChange.z = 0.0f; rigidbody.AddForce(velChange, ForceMode.VelocityChange); //} /* // Calculate how fast we should be moving targetVelocity = new Vector3(inputX * inputModifyFactor, inputY * inputModifyFactor, 0.0f); targetVelocity = myTransform.TransformDirection(targetVelocity); targetVelocity *= climbSpeed; // Apply a force that attempts to reach our target velocity FIXME_VAR_TYPE velChange= (targetVelocity - rigidbody.velocity); velChange.x = Mathf.Clamp(velChange.x, -maxVelocityChange, maxVelocityChange); velChange.y = Mathf.Clamp(velChange.y, -maxVelocityChange, maxVelocityChange); velChange.z = 0.0f; rigidbody.AddForce(velChange, ForceMode.VelocityChange); */ }else{ // AirControl targetVelocity = new Vector3(Input.GetAxis("Horizontal"), 0.0f, Input.GetAxis("Vertical")); targetVelocity = transform.TransformDirection(targetVelocity) * inAirControl; rigidbody.AddForce(targetVelocity, ForceMode.VelocityChange); } } if(onLadder == false){ canClimb = false; } if(canClimb == false){ // Gravity rigidbody.AddForce(Vector3 (0, (-gravity + gravitySkillLevel) * rigidbody.mass, 0)); } grounded = false; onLadder = false; } void OnCollisionStay ( Collision col ){ foreach(ContactPoint contact in col.contacts){ if(Vector3.Angle(contact.normal, Vector3.up) < 45){ grounded = true; } } } void OnTriggerStay ( Collider other ){ if (other.gameObject.tag == "Ladder") { onLadder = true; grounded = false; } } void HitJumpPad ( float velocity ){ rigidbody.velocity.z += velocity; } void OnCollisionEnter ( Collision collision ){ if(grounded == false){ fallAnimGO.animation.CrossFadeQueued("Fall", 0.3f, QueueMode.PlayNow); float currSpeed = collision.relativeVelocity.magnitude; if (currSpeed > 25) { float damage = currSpeed * fallDamageMultiplier; Debug.Log ("FallDamage" + damage); SendMessage ("PlayerDamage", damage, SendMessageOptions.DontRequireReceiver); } } } void CalculateJumpVerticalSpeed (){ return Mathf.Sqrt(2 * jumpHeight * gravity); } void Update (){ if(isRemotePlayer)return; if(grounded){ if ( rigidbody.velocity.magnitude < (walkSpeed+2) && rigidbody.velocity.magnitude > (walkSpeed-2) && !Input.GetButton("Fire2")){ playerWeapons.animation.CrossFade("Walk"); }else if (rigidbody.velocity.magnitude > (runSpeed -2)){ playerWeapons.animation.CrossFade("Run"); }else if (rigidbody.velocity.magnitude < (crouchSpeed+1) && rigidbody.velocity.magnitude > (crouchSpeed-1) && Input.GetButton("Fire2")){ playerWeapons.animation.CrossFade("CrouchAim"); }else{ playerWeapons.animation.CrossFade("IdleAnim"); } }else{ playerWeapons.animation.CrossFade("IdleAnim"); } if(mainCameraGO.transform.localPosition.y > normalHeight){ mainCameraGO.transform.localPosition.y = normalHeight; } else if(mainCameraGO.transform.localPosition.y < proneHeight){ mainCameraGO.transform.localPosition.y = proneHeight; } weaponCameraGO.transform.localPosition.y = mainCameraGO.transform.localPosition.y; if (Input.GetButtonDown("Crouch")) { if(state == 0 || state == 2){ state = 1; } else if(state == 1){ state = 0; } } if(state == 0){ //Stand Position collider.direction = 1; collider.height = 2.0f; collider.center = Vector3 (0, 0, 0); if(mainCameraGO.transform.localPosition.y < normalHeight){ mainCameraGO.transform.localPosition.y += Time.deltaTime * moveSpeed; } }else if(state == 1){ //Crouch Position collider.direction = 1; collider.height = 1.5f; collider.center = Vector3 (0, -0.25f, 0); if(mainCameraGO.transform.localPosition.y > crouchHeight){ if(mainCameraGO.transform.localPosition.y - (crouchingHeight * Time.deltaTime/.1) < crouchHeight){ mainCameraGO.transform.localPosition.y = crouchHeight; } else { mainCameraGO.transform.localPosition.y -= crouchingHeight * Time.deltaTime/.1; } } if(mainCameraGO.transform.localPosition.y < crouchHeight) { if(mainCameraGO.transform.localPosition.y - (crouchingHeight * Time.deltaTime/.1) > crouchHeight) { mainCameraGO.transform.localPosition.y = crouchHeight; } else { mainCameraGO.transform.localPosition.y += crouchingHeight * Time.deltaTime/.1; } } if (Input.GetButtonDown("Jump")){ state = 0; } } else if(state == 2){ //Prone Position collider.direction = 2; collider.height = 0.5f; collider.center = Vector3 (0, -0.5f, 0); if(mainCameraGO.transform.localPosition.y > proneHeight){ mainCameraGO.transform.localPosition.y += proneHeight * Time.deltaTime * (moveSpeed + rigidbody.velocity.magnitude); } if (Input.GetButtonDown("Jump")){ state = 1; } } if (Input.GetButtonDown("GoProne")){ if(state == 0 || state == 1){ state = 2; } else if(state == 2){ state = 0; } } } void Accelerate ( float accelerateY , float accelerateZ ){ grounded = false; rigidbody.AddRelativeForce (0, accelerateY, accelerateZ); } void OnGUI (){ if(onLadder && !canClimb) GUI.Label( new Rect(Screen.width - (Screen.width/1.7f),Screen.height - (Screen.height/1.4f),800,100),"Press key >>E<< to Climb"); } } Converting it to C# to use it with the new network stuff.. its the last piece of the puzzle lol using UnityEngine; using System.Collections; using System.Collections.Generic;
[RequireComponent(typeof(Rigidbody))] [RequireComponent(typeof(CapsuleCollider))] public class RigidController2 : MonoBehaviour { /** * Script written by OMA [FPSPrefab1.3] **/ public bool isRemotePlayer = true; public float proneSpeed = 1.0f; public float crouchSpeed = 2.0f; public float walkSpeed = 8.0f; public float runSpeed = 20.0f; public float runSkillLevel = 0.0f; public float gravitySkillLevel = 0.0f; public int fallDamageMultiplier = 2; GameObject fallAnimGO; public float inAirControl = 0.1f; public float gravity = 20.0f; public float maxVelocityChange = 10.0f; public bool canJump = true; public float jumpHeight = 2.0f; AudioClip fallSound; GameObject playerWeapons; [HideInInspector] public bool grounded = false; private bool sliding = false; private float speed = 10.0f; private bool limitDiagonalSpeed = true; private float normalHeight = 0.5f; private float crouchHeight = -0.2f; private float crouchingHeight = 0.3f; public float proneHeight = -0.7f; private RaycastHit hit; private Transform myTransform; private float rayDistance; private GameObject mainCameraGO; private GameObject weaponCameraGO; int state = 0; float moveSpeed = 2.0f; Vector3 targetVelocity = Vector3.zero; bool onLadder = false; float climbSpeed = 10.0f; bool canClimb = false;
void Awake (){ rigidbody.freezeRotation = true; rigidbody.useGravity = false; myTransform = transform; mainCameraGO = GameObject.FindWithTag("MainCamera"); weaponCameraGO = GameObject.FindWithTag("WeaponCamera"); rayDistance = (collider as CapsuleCollider).height * .5f + (collider as CapsuleCollider).radius; playerWeapons.animation.wrapMode = WrapMode.Loop; } void FixedUpdate (){ if(isRemotePlayer)return; float inputX = Input.GetAxis("Horizontal"); float inputY = Input.GetAxis("Vertical"); float inputModifyFactor = (inputX != 0.0f && inputY != 0.0f && limitDiagonalSpeed)? .7071f : 1.0f; if (grounded){ if(state == 0) { if ( Physics.Raycast(myTransform.position, -Vector3.up, out hit, rayDistance)) { if (Vector3.Angle(hit.normal, Vector3.up) > 30f) { sliding = true; rigidbody.AddRelativeForce (-Vector3.up * 500f); } else { sliding = false; } } } // Calculate how fast we should be moving targetVelocity = new Vector3(inputX * inputModifyFactor, 0.0f, inputY * inputModifyFactor); targetVelocity = myTransform.TransformDirection(targetVelocity); targetVelocity *= speed; // Apply a force that attempts to reach our target velocity Vector3 velocity = rigidbody.velocity; Vector3 velocityChange = (targetVelocity - velocity); velocityChange.x = Mathf.Clamp(velocityChange.x, -maxVelocityChange, maxVelocityChange); velocityChange.z = Mathf.Clamp(velocityChange.z, -maxVelocityChange, maxVelocityChange); velocityChange.y = 0.0f; rigidbody.AddForce(velocityChange, ForceMode.VelocityChange); if (canJump && Input.GetButtonDown("Jump") && state == 0){ rigidbody.velocity = new Vector3(velocity.x, CalculateJumpVerticalSpeed(), velocity.z); } if(Input.GetButton("Use") && onLadder){ canClimb = true; rigidbody.velocity = new Vector3(velocity.x, CalculateJumpVerticalSpeed(), velocity.z); } if(state == 0){ if (grounded && Input.GetButton("Run") && Input.GetKey("w")){ speed = runSpeed + runSkillLevel; }else{ speed = walkSpeed; } }else if(state == 1){ speed = crouchSpeed; }else if(state == 2){ speed = proneSpeed; } }else{ if(onLadder && canClimb){ //if(Input.GetAxis("Vertical")){ targetVelocity = new Vector3(0.0f, Input.GetAxis("Vertical") * inputModifyFactor, 0.0f ); targetVelocity *= climbSpeed; targetVelocity = myTransform.TransformDirection(targetVelocity); Vector3 velChange = (targetVelocity - rigidbody.velocity); velChange.x = Mathf.Clamp(velChange.x, -maxVelocityChange, maxVelocityChange); velChange.y = Mathf.Clamp(velChange.y, -maxVelocityChange, maxVelocityChange); velChange.z = 0.0f; rigidbody.AddForce(velChange, ForceMode.VelocityChange); //} /* // Calculate how fast we should be moving targetVelocity = new Vector3(inputX * inputModifyFactor, inputY * inputModifyFactor, 0.0f); targetVelocity = myTransform.TransformDirection(targetVelocity); targetVelocity *= climbSpeed; // Apply a force that attempts to reach our target velocity FIXME_VAR_TYPE velChange= (targetVelocity - rigidbody.velocity); velChange.x = Mathf.Clamp(velChange.x, -maxVelocityChange, maxVelocityChange); velChange.y = Mathf.Clamp(velChange.y, -maxVelocityChange, maxVelocityChange); velChange.z = 0.0f; rigidbody.AddForce(velChange, ForceMode.VelocityChange); */ }else{ // AirControl targetVelocity = new Vector3(Input.GetAxis("Horizontal"), 0.0f, Input.GetAxis("Vertical")); targetVelocity = transform.TransformDirection(targetVelocity) * inAirControl; rigidbody.AddForce(targetVelocity, ForceMode.VelocityChange); } } if(onLadder == false){ canClimb = false; } if(canClimb == false){ // Gravity rigidbody.AddForce(new Vector3 (0f, (-gravity + gravitySkillLevel) * rigidbody.mass, 0f)); } grounded = false; onLadder = false; } void OnCollisionStay ( Collision col ){ foreach(ContactPoint contact in col.contacts){ if(Vector3.Angle(contact.normal, Vector3.up) < 45f){ grounded = true; } } } void OnTriggerStay ( Collider other ){ if (other.gameObject.tag == "Ladder") { onLadder = true; grounded = false; } } void HitJumpPad ( float velocity ){ Vector3 oldVelocity = rigidbody.velocity; rigidbody.velocity.Set(oldVelocity.x, oldVelocity.y, oldVelocity.z + velocity); } void OnCollisionEnter ( Collision collision ){ if(grounded == false){ fallAnimGO.animation.CrossFadeQueued("Fall", 0.3f, QueueMode.PlayNow); float currSpeed = collision.relativeVelocity.magnitude; if (currSpeed > 25f) { float damage = currSpeed * fallDamageMultiplier; Debug.Log ("FallDamage" + damage); SendMessage ("PlayerDamage", damage, SendMessageOptions.DontRequireReceiver); } } } float CalculateJumpVerticalSpeed (){ return Mathf.Sqrt(2f * jumpHeight * gravity); } void Update (){ if(isRemotePlayer)return; if(grounded){ if ( rigidbody.velocity.magnitude < (walkSpeed + 2f) && rigidbody.velocity.magnitude > (walkSpeed - 2f) && !Input.GetButton("Fire2")){ playerWeapons.animation.CrossFade("Walk"); }else if (rigidbody.velocity.magnitude > (runSpeed - 2f)){ playerWeapons.animation.CrossFade("Run"); }else if (rigidbody.velocity.magnitude < (crouchSpeed + 1f) && rigidbody.velocity.magnitude > (crouchSpeed - 1f) && Input.GetButton("Fire2")){ playerWeapons.animation.CrossFade("CrouchAim"); }else{ playerWeapons.animation.CrossFade("IdleAnim"); } }else{ playerWeapons.animation.CrossFade("IdleAnim"); }
if(mainCameraGO.transform.localPosition.y > normalHeight){ mainCameraGO.transform.localPosition.Set(mainCameraGO.transform.localPosition.x, normalHeight, mainCameraGO.transform.localPosition.z); } else if(mainCameraGO.transform.localPosition.y < proneHeight){ mainCameraGO.transform.localPosition.Set(mainCameraGO.transform.localPosition.x, proneHeight, mainCameraGO.transform.localPosition.z); }
weaponCameraGO.transform.localPosition.Set(weaponCameraGO.transform.localPosition.x, mainCameraGO.transform.localPosition.y, weaponCameraGO.transform.localPosition.z); if (Input.GetButtonDown("Crouch")) { if(state == 0 || state == 2){ state = 1; } else if(state == 1){ state = 0; } } if(state == 0){ //Stand Position (collider as CapsuleCollider).direction = 1; (collider as CapsuleCollider).height = 2.0f; (collider as CapsuleCollider).center = new Vector3 (0f, 0f, 0f); if(mainCameraGO.transform.localPosition.y < normalHeight){ mainCameraGO.transform.Translate(0f, Time.deltaTime * moveSpeed, 0f); } }else if(state == 1){ //Crouch Position (collider as CapsuleCollider).direction = 1; (collider as CapsuleCollider).height = 1.5f; (collider as CapsuleCollider).center = new Vector3 (0f, -0.25f, 0f); if(mainCameraGO.transform.localPosition.y > crouchHeight){ if(mainCameraGO.transform.localPosition.y - (crouchingHeight * Time.deltaTime/.1f) < crouchHeight){ mainCameraGO.transform.localPosition.Set(mainCameraGO.transform.localPosition.x, crouchHeight, mainCameraGO.transform.localPosition.z); } else { mainCameraGO.transform.Translate(0f, -crouchingHeight * Time.deltaTime/.1f, 0f); } } if(mainCameraGO.transform.localPosition.y < crouchHeight) { if(mainCameraGO.transform.localPosition.y - (crouchingHeight * Time.deltaTime/.1f) > crouchHeight) { mainCameraGO.transform.localPosition.Set(mainCameraGO.transform.localPosition.x, crouchHeight, mainCameraGO.transform.localPosition.z); } else { mainCameraGO.transform.Translate(0f, crouchingHeight * Time.deltaTime/.1f, 0f); } } if (Input.GetButtonDown("Jump")){ state = 0; } } else if(state == 2){ //Prone Position (collider as CapsuleCollider).direction = 2; (collider as CapsuleCollider).height = 0.5f; (collider as CapsuleCollider).center = new Vector3 (0f, -0.5f, 0f); if(mainCameraGO.transform.localPosition.y > proneHeight){ mainCameraGO.transform.Translate(0f, proneHeight * Time.deltaTime * (moveSpeed + rigidbody.velocity.magnitude), 0f); } if (Input.GetButtonDown("Jump")){ state = 1; } } if (Input.GetButtonDown("GoProne")){ if(state == 0 || state == 1){ state = 2; } else if(state == 2){ state = 0; } } } void Accelerate ( float accelerateY , float accelerateZ ){ grounded = false; rigidbody.AddRelativeForce (0f, accelerateY, accelerateZ); } void OnGUI (){ if(onLadder && !canClimb) GUI.Label( new Rect(Screen.width - (Screen.width/1.7f),Screen.height - (Screen.height/1.4f),800f,100f),"Press key >>E<< to Climb"); } } WARNING:![](https://ip.bitcointalk.org/?u=http%3A%2F%2Ftheagentalice.com%2Fwp-content%2Fuploads%2F5-dog-no-idea-what-hes-doing-300x229.jpg&t=665&c=xRhvuMKEA1-4ig)
|
DASH: XsV4GHVKGTjQFvwB7c6mYsGV3Mxf7iser6
|
|
|
oldandgrey
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
March 03, 2015, 01:55:06 PM |
|
Yeah updating the prefab would be a good idea!
Lol - focus folks. Let's finish the current demo and interface it to the wallet and then while everyone is killing each other we can roll out the new prefab for any survivors ;-)
|
Coin2.1: UwSmkRvKBUmxQSzJ8N9T5SSy3BBeW86wS Hyper : HVRL9P7tEfG8NBnfuk1Qo26jNsnhxHhZu8
|
|
|
wheelz1200
Legendary
Offline
Activity: 3738
Merit: 1414
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
March 03, 2015, 03:32:16 PM |
|
Lol...seriously this has got to be one of the better crypto communities out there
|
|
|
|
KingArbinV
Legendary
Offline
Activity: 1078
Merit: 1000
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
March 03, 2015, 04:18:05 PM Last edit: March 03, 2015, 05:54:56 PM by KingArbinV |
|
Well I'm excited, I believe Unity is backed into a corner thanks to Unreal making Unreal Engine 4 free, so they might be about to announce Unity5 Pro for Free and release it or just releasing it would be awesome.. either way they are about to make the announcement live, they have even shut their site down and replaced it with a link to the live feed. Kinda makes me mad a bit cause I was trying to look up something for the code, and thanks UdjinM6 but I might have pasted the wrong code into the post I made earlier, I was really tired when I did that, lol. Also I will be gone for a few days and not sure if I will have internet at my aunts or not, so we will see, just don't anyone get heartbroken if I don't make any updates for a few days, lol. /** * Script written by OMA [FPSPrefab1.3] **/ var isRemotePlayer = true; var proneSpeed = 1.0; var crouchSpeed = 2.0; var walkSpeed = 8.0; var runSpeed = 20.0; var runSkillLevel : float = 0.0; var gravitySkillLevel : float = 0.0;
var fallDamageMultiplier : int = 2; var fallAnimGO : GameObject; var inAirControl = 0.1; var gravity = 20.0; var maxVelocityChange = 10.0; var canJump = true; var jumpHeight = 2.0; var fallSound : AudioClip; var playerWeapons : GameObject; //@HideInInspector var grounded = false; private var sliding : boolean = false; private var speed = 10.0; private var limitDiagonalSpeed = true; private var normalHeight : float = 0.5; private var crouchHeight : float = -0.2; private var crouchingHeight = 0.3; var proneHeight : float = -0.7; private var hit : RaycastHit; private var myTransform : Transform; private var rayDistance : float; private var mainCameraGO : GameObject; private var weaponCameraGO : GameObject; var state : int = 0; var moveSpeed : float = 2.0; var targetVelocity : Vector3 = Vector3.zero; var onLadder : boolean = false; var climbSpeed : float = 10.0; var canClimb : boolean = false;
@script RequireComponent(Rigidbody, CapsuleCollider)
function Awake (){ rigidbody.freezeRotation = true; rigidbody.useGravity = false; myTransform = transform; mainCameraGO = gameObject.FindWithTag("MainCamera"); weaponCameraGO = gameObject.FindWithTag("WeaponCamera"); rayDistance = collider.height * .5 + collider.radius; playerWeapons.animation.wrapMode = WrapMode.Loop; }
function FixedUpdate (){
if(isRemotePlayer)return;
var inputX = Input.GetAxis("Horizontal"); var inputY = Input.GetAxis("Vertical"); var inputModifyFactor = (inputX != 0.0 && inputY != 0.0 && limitDiagonalSpeed)? .7071 : 1.0;
if (grounded){ if(state == 0){ if ( Physics.Raycast(myTransform.position, -Vector3.up, hit, rayDistance)) { if (Vector3.Angle(hit.normal, Vector3.up) > 30){ sliding = true; rigidbody.AddRelativeForce (-Vector3.up * 500); }else{ sliding = false; } } }
// Calculate how fast we should be moving targetVelocity = new Vector3(inputX * inputModifyFactor, 0.0, inputY * inputModifyFactor); targetVelocity = myTransform.TransformDirection(targetVelocity); targetVelocity *= speed; // Apply a force that attempts to reach our target velocity var velocity = rigidbody.velocity; var velocityChange = (targetVelocity - velocity); velocityChange.x = Mathf.Clamp(velocityChange.x, -maxVelocityChange, maxVelocityChange); velocityChange.z = Mathf.Clamp(velocityChange.z, -maxVelocityChange, maxVelocityChange); velocityChange.y = 0.0; rigidbody.AddForce(velocityChange, ForceMode.VelocityChange); if (canJump && Input.GetButtonDown("Jump") && state == 0){ rigidbody.velocity = Vector3(velocity.x, CalculateJumpVerticalSpeed(), velocity.z); } if(Input.GetButton("Use") && onLadder){ canClimb = true; rigidbody.velocity = Vector3(velocity.x, CalculateJumpVerticalSpeed(), velocity.z); } if(state == 0){ if (grounded && Input.GetButton("Run") && Input.GetKey("w")){ speed = runSpeed + runSkillLevel; }else{ speed = walkSpeed; } }else if(state == 1){ speed = crouchSpeed; }else if(state == 2){ speed = proneSpeed; } }else{
if(onLadder && canClimb){ //if(Input.GetAxis("Vertical")){ targetVelocity = new Vector3(0.0, Input.GetAxis("Vertical") * inputModifyFactor, 0.0 ); targetVelocity *= climbSpeed; targetVelocity = myTransform.TransformDirection(targetVelocity); var velChange = (targetVelocity - rigidbody.velocity); velChange.x = Mathf.Clamp(velChange.x, -maxVelocityChange, maxVelocityChange); velChange.y = Mathf.Clamp(velChange.y, -maxVelocityChange, maxVelocityChange); velChange.z = 0.0; rigidbody.AddForce(velChange, ForceMode.VelocityChange); //} /* // Calculate how fast we should be moving targetVelocity = new Vector3(inputX * inputModifyFactor, inputY * inputModifyFactor, 0.0); targetVelocity = myTransform.TransformDirection(targetVelocity); targetVelocity *= climbSpeed; // Apply a force that attempts to reach our target velocity var velChange = (targetVelocity - rigidbody.velocity); velChange.x = Mathf.Clamp(velChange.x, -maxVelocityChange, maxVelocityChange); velChange.y = Mathf.Clamp(velChange.y, -maxVelocityChange, maxVelocityChange); velChange.z = 0.0; rigidbody.AddForce(velChange, ForceMode.VelocityChange); */ }else{ // AirControl targetVelocity = new Vector3(Input.GetAxis("Horizontal"), 0.0, Input.GetAxis("Vertical")); targetVelocity = transform.TransformDirection(targetVelocity) * inAirControl; rigidbody.AddForce(targetVelocity, ForceMode.VelocityChange); } } if(onLadder == false){ canClimb = false; } if(canClimb == false){ // Gravity rigidbody.AddForce(Vector3 (0, (-gravity + gravitySkillLevel) * rigidbody.mass, 0)); } grounded = false; onLadder = false; }
function OnCollisionStay (col : Collision){ for(var contact : ContactPoint in col.contacts){ if(Vector3.Angle(contact.normal, Vector3.up) < 45){ grounded = true; } } }
function OnTriggerStay(other : Collider){ if (other.gameObject.tag == "Ladder") { onLadder = true; grounded = false; } }
function HitJumpPad(velocity : float) { rigidbody.velocity.z += velocity; }
function OnCollisionEnter (collision : Collision){ if(grounded == false){ fallAnimGO.animation.CrossFadeQueued("Fall", 0.3, QueueMode.PlayNow); var currSpeed : float = collision.relativeVelocity.magnitude; if (currSpeed > 25) { var damage : float = currSpeed * fallDamageMultiplier; Debug.Log ("FallDamage" + damage); SendMessage ("PlayerDamage", damage, SendMessageOptions.DontRequireReceiver); } } }
function CalculateJumpVerticalSpeed (){ return Mathf.Sqrt(2 * jumpHeight * gravity); }
function Update(){ if(isRemotePlayer)return; if(grounded){ if ( rigidbody.velocity.magnitude < (walkSpeed+2) && rigidbody.velocity.magnitude > (walkSpeed-2) && !Input.GetButton("Fire2")){ playerWeapons.animation.CrossFade("Walk"); }else if (rigidbody.velocity.magnitude > (runSpeed -2)){ playerWeapons.animation.CrossFade("Run"); }else if (rigidbody.velocity.magnitude < (crouchSpeed+1) && rigidbody.velocity.magnitude > (crouchSpeed-1) && Input.GetButton("Fire2")){ playerWeapons.animation.CrossFade("CrouchAim"); }else{ playerWeapons.animation.CrossFade("IdleAnim"); } }else{ playerWeapons.animation.CrossFade("IdleAnim"); } if(mainCameraGO.transform.localPosition.y > normalHeight){ mainCameraGO.transform.localPosition.y = normalHeight; } else if(mainCameraGO.transform.localPosition.y < proneHeight){ mainCameraGO.transform.localPosition.y = proneHeight; } weaponCameraGO.transform.localPosition.y = mainCameraGO.transform.localPosition.y;
if (Input.GetButtonDown("Crouch")) { if(state == 0 || state == 2){ state = 1; } else if(state == 1){ state = 0; } }
if(state == 0){ //Stand Position collider.direction = 1; collider.height = 2.0; collider.center = Vector3 (0, 0, 0); if(mainCameraGO.transform.localPosition.y < normalHeight){ mainCameraGO.transform.localPosition.y += Time.deltaTime * moveSpeed; }
}else if(state == 1){ //Crouch Position collider.direction = 1; collider.height = 1.5; collider.center = Vector3 (0, -0.25, 0); if(mainCameraGO.transform.localPosition.y > crouchHeight){ if(mainCameraGO.transform.localPosition.y - (crouchingHeight * Time.deltaTime/.1) < crouchHeight){ mainCameraGO.transform.localPosition.y = crouchHeight; } else { mainCameraGO.transform.localPosition.y -= crouchingHeight * Time.deltaTime/.1; } } if(mainCameraGO.transform.localPosition.y < crouchHeight){ if(mainCameraGO.transform.localPosition.y - (crouchingHeight * Time.deltaTime/.1) > crouchHeight){ mainCameraGO.transform.localPosition.y = crouchHeight; } else { mainCameraGO.transform.localPosition.y += crouchingHeight * Time.deltaTime/.1; } } if (Input.GetButtonDown("Jump")){ state = 0; } } else if(state == 2){ //Prone Position collider.direction = 2; collider.height = 0.5; collider.center = Vector3 (0, -0.5, 0); if(mainCameraGO.transform.localPosition.y > proneHeight){ mainCameraGO.transform.localPosition.y += proneHeight * Time.deltaTime * (moveSpeed + rigidbody.velocity.magnitude); } if (Input.GetButtonDown("Jump")){ state = 1; } } if (Input.GetButtonDown("GoProne")){ if(state == 0 || state == 1){ state = 2; } else if(state == 2){ state = 0; } } }
function Accelerate (accelerateY : float, accelerateZ : float){ grounded = false; rigidbody.AddRelativeForce (0, accelerateY, accelerateZ); }
function OnGUI(){ if(onLadder && !canClimb) GUI.Label(Rect(Screen.width - (Screen.width/1.7),Screen.height - (Screen.height/1.4),800,100),"Press key >>E<< to Climb"); } This is the code I was converting, it was written in JavaScript, and I need to rewrite it in C# but either way Nrigo saved me alot of trouble with the new kit except for one thing, the player does not have an actual body.. so Dominic will have to take the current player body and arms and replace the ones in the premium kit, but the scripts for it should work still, so we should be good to go on that much. Getting it networking ready shouldn't be too big a deal either with all the new scripts we need already written in C#, makes things much easier =D. No need to continue with the old demo, but I do vote for keeping the spiders, lol.. their not in the premium FPS kit at all.. Other than keeping the spiders, the maps need imported to the new setup, not really a problem, just a few hours worth of work, and my idea Garfield is while they are killing each other once we get networking going(it really is an asshole) we can begin integrating and setting up Coin Shop, Nikhil provided a model of a Futuristic Assult Rifle he made to me earlier, and it will be one of the first items sold for actual Coin2.
|
World without fiats!
|
|
|
Abbott_Car
Newbie
Offline
Activity: 28
Merit: 0
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
March 03, 2015, 04:19:11 PM |
|
i agree, i just wanted to remind the comunity to have their wallets up and running, staking, we need secure network.
|
|
|
|
KingArbinV
Legendary
Offline
Activity: 1078
Merit: 1000
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
March 03, 2015, 04:34:29 PM |
|
|
World without fiats!
|
|
|
UdjinM6
Legendary
Offline
Activity: 1318
Merit: 1040
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
March 03, 2015, 05:17:46 PM Last edit: March 03, 2015, 06:09:54 PM by UdjinM6 |
|
Well I'm excited, I believe Unity is backed into a corner thanks to Unreal making Unreal Engine 4 free, so they might be about to announce Unity5 Pro for Free and release it or just releasing it would be awesome.. either way they are about to make the announcement live, they have even shut their site down and replaced it with a link to the live feed. Kinda makes me mad a bit cause I was trying to look up something for the code, and thanks UdjinM6 but I might have pasted the wrong code into the post I made earlier, I was really tired when I did that, lol. Also I will be gone for a few days and not sure if I will have internet at my aunts or not, so we will see, just don't anyone get heartbroken if I don't make any updates for a few days, lol. /** * Script written by OMA [FPSPrefab1.3] **/ var isRemotePlayer = true; var proneSpeed = 1.0; var crouchSpeed = 2.0; var walkSpeed = 8.0; var runSpeed = 20.0; var runSkillLevel : float = 0.0; var gravitySkillLevel : float = 0.0;
var fallDamageMultiplier : int = 2; var fallAnimGO : GameObject; var inAirControl = 0.1; var gravity = 20.0; var maxVelocityChange = 10.0; var canJump = true; var jumpHeight = 2.0; var fallSound : AudioClip; var playerWeapons : GameObject; //@HideInInspector var grounded = false; private var sliding : boolean = false; private var speed = 10.0; private var limitDiagonalSpeed = true; private var normalHeight : float = 0.5; private var crouchHeight : float = -0.2; private var crouchingHeight = 0.3; var proneHeight : float = -0.7; private var hit : RaycastHit; private var myTransform : Transform; private var rayDistance : float; private var mainCameraGO : GameObject; private var weaponCameraGO : GameObject; var state : int = 0; var moveSpeed : float = 2.0; var targetVelocity : Vector3 = Vector3.zero; var onLadder : boolean = false; var climbSpeed : float = 10.0; var canClimb : boolean = false;
@script RequireComponent(Rigidbody, CapsuleCollider)
function Awake (){ rigidbody.freezeRotation = true; rigidbody.useGravity = false; myTransform = transform; mainCameraGO = gameObject.FindWithTag("MainCamera"); weaponCameraGO = gameObject.FindWithTag("WeaponCamera"); rayDistance = collider.height * .5 + collider.radius; playerWeapons.animation.wrapMode = WrapMode.Loop; }
function FixedUpdate (){
if(isRemotePlayer)return;
var inputX = Input.GetAxis("Horizontal"); var inputY = Input.GetAxis("Vertical"); var inputModifyFactor = (inputX != 0.0 && inputY != 0.0 && limitDiagonalSpeed)? .7071 : 1.0;
if (grounded){ if(state == 0){ if ( Physics.Raycast(myTransform.position, -Vector3.up, hit, rayDistance)) { if (Vector3.Angle(hit.normal, Vector3.up) > 30){ sliding = true; rigidbody.AddRelativeForce (-Vector3.up * 500); }else{ sliding = false; } } }
// Calculate how fast we should be moving targetVelocity = new Vector3(inputX * inputModifyFactor, 0.0, inputY * inputModifyFactor); targetVelocity = myTransform.TransformDirection(targetVelocity); targetVelocity *= speed; // Apply a force that attempts to reach our target velocity var velocity = rigidbody.velocity; var velocityChange = (targetVelocity - velocity); velocityChange.x = Mathf.Clamp(velocityChange.x, -maxVelocityChange, maxVelocityChange); velocityChange.z = Mathf.Clamp(velocityChange.z, -maxVelocityChange, maxVelocityChange); velocityChange.y = 0.0; rigidbody.AddForce(velocityChange, ForceMode.VelocityChange); if (canJump && Input.GetButtonDown("Jump") && state == 0){ rigidbody.velocity = Vector3(velocity.x, CalculateJumpVerticalSpeed(), velocity.z); } if(Input.GetButton("Use") && onLadder){ canClimb = true; rigidbody.velocity = Vector3(velocity.x, CalculateJumpVerticalSpeed(), velocity.z); } if(state == 0){ if (grounded && Input.GetButton("Run") && Input.GetKey("w")){ speed = runSpeed + runSkillLevel; }else{ speed = walkSpeed; } }else if(state == 1){ speed = crouchSpeed; }else if(state == 2){ speed = proneSpeed; } }else{
if(onLadder && canClimb){ //if(Input.GetAxis("Vertical")){ targetVelocity = new Vector3(0.0, Input.GetAxis("Vertical") * inputModifyFactor, 0.0 ); targetVelocity *= climbSpeed; targetVelocity = myTransform.TransformDirection(targetVelocity); var velChange = (targetVelocity - rigidbody.velocity); velChange.x = Mathf.Clamp(velChange.x, -maxVelocityChange, maxVelocityChange); velChange.y = Mathf.Clamp(velChange.y, -maxVelocityChange, maxVelocityChange); velChange.z = 0.0; rigidbody.AddForce(velChange, ForceMode.VelocityChange); //} /* // Calculate how fast we should be moving targetVelocity = new Vector3(inputX * inputModifyFactor, inputY * inputModifyFactor, 0.0); targetVelocity = myTransform.TransformDirection(targetVelocity); targetVelocity *= climbSpeed; // Apply a force that attempts to reach our target velocity var velChange = (targetVelocity - rigidbody.velocity); velChange.x = Mathf.Clamp(velChange.x, -maxVelocityChange, maxVelocityChange); velChange.y = Mathf.Clamp(velChange.y, -maxVelocityChange, maxVelocityChange); velChange.z = 0.0; rigidbody.AddForce(velChange, ForceMode.VelocityChange); */ }else{ // AirControl targetVelocity = new Vector3(Input.GetAxis("Horizontal"), 0.0, Input.GetAxis("Vertical")); targetVelocity = transform.TransformDirection(targetVelocity) * inAirControl; rigidbody.AddForce(targetVelocity, ForceMode.VelocityChange); } } if(onLadder == false){ canClimb = false; } if(canClimb == false){ // Gravity rigidbody.AddForce(Vector3 (0, (-gravity + gravitySkillLevel) * rigidbody.mass, 0)); } grounded = false; onLadder = false; }
function OnCollisionStay (col : Collision){ for(var contact : ContactPoint in col.contacts){ if(Vector3.Angle(contact.normal, Vector3.up) < 45){ grounded = true; } } }
function OnTriggerStay(other : Collider){ if (other.gameObject.tag == "Ladder") { onLadder = true; grounded = false; } }
function HitJumpPad(velocity : float) { rigidbody.velocity.z += velocity; }
function OnCollisionEnter (collision : Collision){ if(grounded == false){ fallAnimGO.animation.CrossFadeQueued("Fall", 0.3, QueueMode.PlayNow); var currSpeed : float = collision.relativeVelocity.magnitude; if (currSpeed > 25) { var damage : float = currSpeed * fallDamageMultiplier; Debug.Log ("FallDamage" + damage); SendMessage ("PlayerDamage", damage, SendMessageOptions.DontRequireReceiver); } } }
function CalculateJumpVerticalSpeed (){ return Mathf.Sqrt(2 * jumpHeight * gravity); }
function Update(){ if(isRemotePlayer)return; if(grounded){ if ( rigidbody.velocity.magnitude < (walkSpeed+2) && rigidbody.velocity.magnitude > (walkSpeed-2) && !Input.GetButton("Fire2")){ playerWeapons.animation.CrossFade("Walk"); }else if (rigidbody.velocity.magnitude > (runSpeed -2)){ playerWeapons.animation.CrossFade("Run"); }else if (rigidbody.velocity.magnitude < (crouchSpeed+1) && rigidbody.velocity.magnitude > (crouchSpeed-1) && Input.GetButton("Fire2")){ playerWeapons.animation.CrossFade("CrouchAim"); }else{ playerWeapons.animation.CrossFade("IdleAnim"); } }else{ playerWeapons.animation.CrossFade("IdleAnim"); } if(mainCameraGO.transform.localPosition.y > normalHeight){ mainCameraGO.transform.localPosition.y = normalHeight; } else if(mainCameraGO.transform.localPosition.y < proneHeight){ mainCameraGO.transform.localPosition.y = proneHeight; } weaponCameraGO.transform.localPosition.y = mainCameraGO.transform.localPosition.y;
if (Input.GetButtonDown("Crouch")) { if(state == 0 || state == 2){ state = 1; } else if(state == 1){ state = 0; } }
if(state == 0){ //Stand Position collider.direction = 1; collider.height = 2.0; collider.center = Vector3 (0, 0, 0); if(mainCameraGO.transform.localPosition.y < normalHeight){ mainCameraGO.transform.localPosition.y += Time.deltaTime * moveSpeed; }
}else if(state == 1){ //Crouch Position collider.direction = 1; collider.height = 1.5; collider.center = Vector3 (0, -0.25, 0); if(mainCameraGO.transform.localPosition.y > crouchHeight){ if(mainCameraGO.transform.localPosition.y - (crouchingHeight * Time.deltaTime/.1) < crouchHeight){ mainCameraGO.transform.localPosition.y = crouchHeight; } else { mainCameraGO.transform.localPosition.y -= crouchingHeight * Time.deltaTime/.1; } } if(mainCameraGO.transform.localPosition.y < crouchHeight){ if(mainCameraGO.transform.localPosition.y - (crouchingHeight * Time.deltaTime/.1) > crouchHeight){ mainCameraGO.transform.localPosition.y = crouchHeight; } else { mainCameraGO.transform.localPosition.y += crouchingHeight * Time.deltaTime/.1; } } if (Input.GetButtonDown("Jump")){ state = 0; } } else if(state == 2){ //Prone Position collider.direction = 2; collider.height = 0.5; collider.center = Vector3 (0, -0.5, 0); if(mainCameraGO.transform.localPosition.y > proneHeight){ mainCameraGO.transform.localPosition.y += proneHeight * Time.deltaTime * (moveSpeed + rigidbody.velocity.magnitude); } if (Input.GetButtonDown("Jump")){ state = 1; } } if (Input.GetButtonDown("GoProne")){ if(state == 0 || state == 1){ state = 2; } else if(state == 2){ state = 0; } } }
function Accelerate (accelerateY : float, accelerateZ : float){ grounded = false; rigidbody.AddRelativeForce (0, accelerateY, accelerateZ); }
function OnGUI(){ if(onLadder && !canClimb) GUI.Label(Rect(Screen.width - (Screen.width/1.7),Screen.height - (Screen.height/1.4),800,100),"Press key >>E<< to Climb"); } This is the code I was converting, it was written in JavaScript, and I need to rewrite it in C# but either way Nrigo saved me alot of trouble with the new kit except for one thing, the player does not have an actual body.. so Dominic will have to take the current player body and arms and replace the ones in the premium kit, but the scripts for it should work still, so we should be good to go on that much. Getting it networking ready shouldn't be too big a deal either with all the new scripts we need already written in C#, makes things much easier =D. No need to continue with the old demo, but I do vote for keeping the spiders, lol.. their not in the premium FPS kit at all.. Other than keeping the spiders, the maps need imported to the new setup, not really a problem, just a few hours worth of work, and my idea Garfield is while they are killing each other once we get networking going(it really is an asshole) we can begin integrating and setting up Coin Shop, Nikhil provided a model of a Futuristic Assult Rifle he made to me earlier, and it will be one of the first items sold for actual Coin2. Btw that warning was for my code not for yours - I have no idea is it ok or no for the whole project but there should be no compiling errors ![Smiley](https://bitcointalk.org/Smileys/default/smiley.gif) Try it, it should work the same that the one you posted in JS. ![Wink](https://bitcointalk.org/Smileys/default/wink.gif)
|
DASH: XsV4GHVKGTjQFvwB7c6mYsGV3Mxf7iser6
|
|
|
oldandgrey
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
March 03, 2015, 05:22:37 PM |
|
Just listening to the video. Sounds amazing!!! and personal edition - Free!!! Love the new sound system (really a musician at heart).
|
Coin2.1: UwSmkRvKBUmxQSzJ8N9T5SSy3BBeW86wS Hyper : HVRL9P7tEfG8NBnfuk1Qo26jNsnhxHhZu8
|
|
|
oldandgrey
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
March 03, 2015, 05:43:53 PM |
|
Just listening to the video. Sounds amazing!!! and personal edition - Free!!! Love the new sound system (really a musician at heart). Web GL 2.0 performance and IL2cpp performance awesome!!!
|
Coin2.1: UwSmkRvKBUmxQSzJ8N9T5SSy3BBeW86wS Hyper : HVRL9P7tEfG8NBnfuk1Qo26jNsnhxHhZu8
|
|
|
zyronx
Legendary
Offline
Activity: 1078
Merit: 1001
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
March 03, 2015, 06:03:05 PM |
|
This is good news for game development. Unity 5 is free. And Unreal Engine 4 is also free! Now there is no excuse for not making cool games! Well, I still have a excuse, I need a better computer! LOL!
|
|
|
|
|
nickquest
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
March 05, 2015, 12:12:01 AM |
|
I didn't think you could still trade on bter. I'm just waiting to try and withdraw my c2 from them. Pretty cool news about Unity.
|
|
|
|
|
souljah1h
Legendary
Offline
Activity: 1092
Merit: 1000
Hyperspace snail
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
March 05, 2015, 02:23:16 PM |
|
Anyone knows how much coins are stuck @ bter?
|
_@/'
|
|
|
|