Quantcast
Channel: Questions in topic: "addforce"
Viewing all articles
Browse latest Browse all 1264

jump script : 2D

$
0
0
hello everyone, I am trying to make my character(Plane gameobject) double jump.. I am developing 2d game and i have animated zombie character running in x-y plane.. My zombie character is not the 3D model.. Script which i have written associated with this zombie character is here : public var maxSpeed : float ; public var minSpeed : float ; public var jump : int = 10; public var dJump : int = 7; public var isJumping : boolean = false; public var isDJumping : boolean = false; public var gravity : int = 20; private var x : float; private var y : float; private var z : float; private var currentSpeed : float; private var stop : boolean = false; private var velocity : Vector3 = Vector3.zero; private static var fenceEnemy : int; function Start () { SetPositionandSpeed(); } function Update () { var amttomove : float = currentSpeed * Time.deltaTime; //velocity = Vector3 (0, 0, ); if(!stop) transform.Translate(Vector3.left * amttomove , Space.World); if(isJumping) { rigidbody.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionZ; rigidbody.AddForce(Vector3.up * jump); isJumping = false; } else { rigidbody.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ; } //rigidbody.velocity.y -= gravity * Time.deltaTime; } function SetPositionandSpeed() { currentSpeed = Random.Range(minSpeed , maxSpeed); x = 12.00; z = -5.00f; y = Random.Range(-6.0f , 1.5f); transform.position = new Vector3(x , y , z); } Now when i shoot the zombie i want to make double jump kind of effect.. So what can i do ? Have tried above code but could not able to get the result.. Please help me.. Thanks in advance for your support and help..

Viewing all articles
Browse latest Browse all 1264

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>