I’m writing a knockback script but has failed.
this code is gives error =![]()
rb2d.AddForce(new Vector3(-kbDirection.x * -100, -kbDirection.y * kbPower, transform.position.z));
All codes
using UnityEngine;
using System.Collections;
using UnityStandardAssets.CrossPlatformInput;
using UnityEngine.UI;
public class Player : MonoBehaviour
{
public float moveForce = 5;
public float boostMultiplier = 20;
Rigidbody2D myBody;
//State
public int curHealth;
public int maxHealth = 5;
private Rigidbody2D rb2d;
private Player player;
private GameMaster gm;
public void resetPosition()
{
transform.position = Vector3.zero;
myBody.velocity = Vector3.zero;
}
void Start()
{
myBody = GetComponent<Rigidbody2D>();
gm = GameObject.FindGameObjectWithTag("GameMaster").GetComponent<GameMaster>();
curHealth = maxHealth;
}
void Update()
{
Vector2 moveVec = new Vector2(CrossPlatformInputManager.GetAxis("Horizontal"),
CrossPlatformInputManager.GetAxis(" ")) * moveForce;
bool isBoosting = CrossPlatformInputManager.GetButton("Boost");
myBody.AddForce(moveVec * (isBoosting ? boostMultiplier : 1));
if (CrossPlatformInputManager.GetButton("Jump"))
transform.Translate(Vector3.up * 4 * Time.deltaTime);
if (curHealth > maxHealth)
{
curHealth = maxHealth;
}
if (curHealth <= 0)
{
curHealth = 0;
Die();
}
}
void OnTriggerEnter2D(Collider2D col)
{
if (col.CompareTag("Coin"))
{
Destroy(col.gameObject);
gm.points += 1;
}
}
void Die()
{
Application.LoadLevel(Application.loadedLevel);
}
public void Damage(int dmg)
{
if (curHealth < dmg)
{
dmg = curHealth;
}
curHealth -= dmg;
gameObject.GetComponent<Animation>().Play("Player_RedFlash");
}
public IEnumerator Knockback(float kbDuration, float kbPower, Vector3 kbDirection)
{
float timer = 0;
while (kbDuration > timer)
{
timer += Time.deltaTime;
rb2d.AddForce(new Vector3(-kbDirection.x * -100, -kbDirection.y * kbPower, transform.position.z));
yield return 0;
}
}
}
please help
– umutxmenOk, i use 3d text mesh and its ok but result is weird i get echo message from php script if ($numrows == 0) { echo"aaa"; } http://i67.tinypic.com/2ai2614.png
– trjfjfgjf