网页资讯视频图片知道文库贴吧地图采购
进入贴吧全吧搜索

 
 
 
日一二三四五六
       
       
       
       
       
       

签到排名:今日本吧第个签到,

本吧因你更精彩,明天继续来努力!

本吧签到人数:0

一键签到
成为超级会员,使用一键签到
一键签到
本月漏签0次!
0
成为超级会员,赠送8张补签卡
如何使用?
点击日历上漏签日期,即可进行补签。
连续签到:天  累计签到:天
0
超级会员单次开通12个月以上,赠送连续签到卡3张
使用连续签到卡
11月19日漏签0天
unity吧 关注:51,992贴子:145,385
  • 看贴

  • 图片

  • 吧主推荐

  • 游戏

  • 1回复贴,共1页
<<返回unity吧
>0< 加载中...

求助各位朋友 2d如何实现 角色跳跃后 重力反转效果 往上掉

  • 只看楼主
  • 收藏

  • 回复
  • LLLHIKKI
  • 默默无闻
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
RT 小弟小白 用的2d playground的移动和跳跃脚本 想实现跳跃后重力反转 然后掉到天花板上去(接触天花板时角色能自动反转的功能能告诉就更好啦),再次跳跃后又重复反转,类似以前ios的游戏gentlemen的那个效果,谢谢各位。跳跃脚本如下
using UnityEngine;
using System.Collections;
[AddComponentMenu("Playground/Movement/Jump")]
[RequireComponent(typeof(Rigidbody2D))]
public class Jump : Physics2DObject
{
[Header("Jump setup")]
// the key used to activate the push
public KeyCode key = KeyCode.Space;
// strength of the push
public float jumpStrength = 10f;
[Header("Ground setup")]
//if the object collides with another object tagged as this, it can jump again
public string groundTag = "Ground";
//this determines if the script has to check for when the player touches the ground to enable him to jump again
//if not, the player can jump even while in the air
public bool checkGround = true;
private bool canJump = true;
// Read the input from the player
void Update()
{
if(canJump
&& Input.GetKeyDown(key))
{
// Apply an instantaneous upwards force
rigidbody2D.AddForce(Vector2.up * jumpStrength, ForceMode2D.Impulse);
canJump = !checkGround;
}
}
private void OnCollisionEnter2D(Collision2D collisionData)
{
if(checkGround
&& collisionData.gameObject.CompareTag(groundTag))
{
canJump = true;
}
}
}


  • LLLHIKKI
  • 默默无闻
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
c#还没开始学习 所以自己改code有点力不从心。。。。


登录百度账号

扫二维码下载贴吧客户端

下载贴吧APP
看高清直播、视频!
  • 贴吧页面意见反馈
  • 违规贴吧举报反馈通道
  • 贴吧违规信息处理公示
  • 1回复贴,共1页
<<返回unity吧
分享到:
©2025 Baidu贴吧协议|隐私政策|吧主制度|意见反馈|网络谣言警示