我一直试图让我的球员向前跳一段时间,但我被卡住了。我看过其他答案并尝试过,但我无法让它以我想要的方式工作。我已经尝试了几种不同的方法,但没有一种方法是按照预期的方式工作的。大多数时候,弹跳的距离是不一样的,有时当球员落地时,球员会向前滑动,这不是我想要的。我想让我的角色像在Crossy road那样跳跃。这是我尝试过的一件事:
using UnityEngine;
using System.Collections;
public class MovePlayer : MonoBehaviour
{
Vector3 endPos;
int numBackwards = 0
我让我的玩家不断下降在屏幕上,当玩家与其他游戏对象交互时,我想销毁这些游戏对象,并希望玩家继续下降。
但一旦玩家击中了另一个游戏对象,游戏对象就会被摧毁,但玩家将停止掉队。请帮我指点我做错了什么。
//Script attached to player:
//x-axis movement speed
public float playerMoveSpeed = 0.2f;
//how much force to act against the gravity
public float upForce = 9.0f;
//horizontal control
刚刚开始学习教程,我想不断地提高我的球的速度,但该死的,我的数学太差了,我甚至不知道该怎么做,这是我目前所做的: // I'm giving the first force (random x) when you engage the ball, in the Start method
System.Random xForce = new System.Random();
rigidBody.AddForce(new Vector2(xForce.Next((int)-speed, (int)speed), speed);
// Later, in the Update c
我已经能够让我的精灵跳到一个我正在统一制作的盘子里。我似乎不能让他跳到一定的高度或距离,但每次他跳起来就像他在月球上跳一样,有什么建议吗?这是我的密码:
using UnityEngine;
using System.Collections;
public class playerScript : MonoBehaviour {
public bool grounded = true;
public float jumpPower = 190;
public float jumpSpeed = 100f;
private bool hasJumped = false
我有一个玩家和一个敌人方为我的2D游戏(技术上它是一个立方体,但它被渲染为一个2D字符)。我有一个RigidBody2D附在玩家和敌人的每一个,连同一个BoxCollider2D,并在他们两个的触发点。然而,当我取消勾选触发器时,运动就会大大增加。这似乎是触发器被勾选导致整个事件被更新得更快,但我不确定。有人能帮忙吗?
修复我需要关闭自动质量在Rigidbody2D。谢谢@DMGregory
敌方法典:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ene
我如何告诉Eclipse不要在每次跳转到对象的函数时都跳到每个文件的第一行?
如果我选择单步执行一个对象的成员函数,Eclipse会打开相应的文件,但它不是直接跳到该函数,而是始终跳到第一行。
package org.diango.simcalc.pipeline; // <-- This is where the debugger "stops"
import org.apache.commons.lang.NullArgumentException;
// .. imagine more code
这实在是太烦人了。
我是Unity的新手,所以我怎么做可能不是最好的方式,但当角色跳跃时,它是不一致的。
有些反弹比其他反弹要远得多,我不确定为什么会发生这种情况。
另外,如果我快速按向上键,立方体会跳得很远,但如果我再等几秒钟,它就会正常反弹。
下面是我的代码:
using UnityEngine;
using System.Collections;
public class MovePlayer : MonoBehaviour
{
Vector3 endPos;
int numBackwards = 0;
bool jumping = false;
public Rig
好的,最后一个问题,我已经用Common Lisp完成了我的猜数游戏!:D每当游戏开始时(或者在第一个游戏之后新的游戏开始),下面的函数被调用。
;;; Play the game
(defun play ()
;; If it's their first time playing this session,
;; make sure to greet the user.
(unless (> *number-of-guesses* 0)
(welcome-user))
;; Reset their remaining guesse
因此,我已经完成了滚动,一个来自统一的球教程,这是一个小游戏,使用一个带有刚体的球体,用一些基本的运动脚本,找到了。
我现在想要的是更进一步,并引入一个更先进的运动脚本,它也可以使用鼠标输入。
我试图实现的是在局部轴的基础上增加力,所以如果我移动鼠标左转,球就会转动,这个力就会朝这个方向增加。让我展示我想出的代码(添加到一个简单的应用刚体的球体中):
using UnityEngine;
using System.Collections;
public class playerController : MonoBehaviour {
public float turnSpeed =
我正在试着让立方体(这是一个二维物体)在地面上跳起来,这是代码,你知道我是如何尝试其他方法的吗,但它们都不起作用
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class playercontroler : MonoBehaviour
{
public int thrust = 5;
public bool OnGround;
Rigidbody2D Rigidbody;
public float Speed = 7;
voi