HTML код для вашего блога :
если в веб демке подъехать задом к стене то шар начнет подниматьсяпо стене или лететь , если без стенки.
У меня вопрос, как решить эту проблему?
скрипт движения:
Синтаксис:
Используется javascript
var force=10;
var torque = 10;
var _IsJumping = false;
var jump = 300;
function Start(){
Screen.lockCursor = true;
}
function OnCollisionEnter(collision : Collision) {
for (var contact : ContactPoint in collision.contacts) {
_IsJumping = false;
}
}
function FixedUpdate() {
var cameraTransform = Camera.main.transform;
// Forward vector relative to the camera along the x-z plane
var forward = cameraTransform.TransformDirection(Vector3.forward);
forward = forward.normalized;
// Right vector relative to the camera
// Always orthogonal to the forward vector
var right = Vector3(forward.z, 0, -forward.x);
var TorqueRight = Vector3(forward.x, 0, forward.z);
if (Input.GetKeyDown ("r")) {
Application.LoadLevel(0);
}
if (Input.GetKey ("a")&& !_IsJumping) {
rigidbody.AddForce(right * -force, ForceMode.Acceleration);
}
if (Input.GetKey ("a")) {
rigidbody.AddTorque(TorqueRight * torque);
}
if (Input.GetKey("d")&& !_IsJumping) {
rigidbody.AddForce(right * force, ForceMode.Acceleration);
}
if (Input.GetKey("d")) {
rigidbody.AddTorque(TorqueRight * -torque);
}
if (Input.GetKey("w")&& !_IsJumping) {
rigidbody.AddForce(forward * force, ForceMode.Acceleration);
}
if (Input.GetKey("w")) {
rigidbody.AddTorque(right * torque);
}
if (Input.GetKey ("s")&& !_IsJumping) {
rigidbody.AddForce(forward * -force, ForceMode.Acceleration);
}
if (Input.GetKey ("s")) {
rigidbody.AddTorque(right * -torque);
}
if (Input.GetKey ("space")&& !_IsJumping) {
_IsJumping = true;
rigidbody.AddForce(0,jump,0);
}
}
var torque = 10;
var _IsJumping = false;
var jump = 300;
function Start(){
Screen.lockCursor = true;
}
function OnCollisionEnter(collision : Collision) {
for (var contact : ContactPoint in collision.contacts) {
_IsJumping = false;
}
}
function FixedUpdate() {
var cameraTransform = Camera.main.transform;
// Forward vector relative to the camera along the x-z plane
var forward = cameraTransform.TransformDirection(Vector3.forward);
forward = forward.normalized;
// Right vector relative to the camera
// Always orthogonal to the forward vector
var right = Vector3(forward.z, 0, -forward.x);
var TorqueRight = Vector3(forward.x, 0, forward.z);
if (Input.GetKeyDown ("r")) {
Application.LoadLevel(0);
}
if (Input.GetKey ("a")&& !_IsJumping) {
rigidbody.AddForce(right * -force, ForceMode.Acceleration);
}
if (Input.GetKey ("a")) {
rigidbody.AddTorque(TorqueRight * torque);
}
if (Input.GetKey("d")&& !_IsJumping) {
rigidbody.AddForce(right * force, ForceMode.Acceleration);
}
if (Input.GetKey("d")) {
rigidbody.AddTorque(TorqueRight * -torque);
}
if (Input.GetKey("w")&& !_IsJumping) {
rigidbody.AddForce(forward * force, ForceMode.Acceleration);
}
if (Input.GetKey("w")) {
rigidbody.AddTorque(right * torque);
}
if (Input.GetKey ("s")&& !_IsJumping) {
rigidbody.AddForce(forward * -force, ForceMode.Acceleration);
}
if (Input.GetKey ("s")) {
rigidbody.AddTorque(right * -torque);
}
if (Input.GetKey ("space")&& !_IsJumping) {
_IsJumping = true;
rigidbody.AddForce(0,jump,0);
}
}