CocosCreator of KUOKUO teach you to use 2D physics collision line and cross 3D cool running

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/kuokuo666/article/details/97944894
Engine Version

CocosCreator v2.1.2 version can not be lower than 2.1.1

Show

Here Insert Picture Description
Two platforms a jump box, which you can do by horizontal version of 3D to run cool yo!

Production process

Create a new project, then add platform (Box)
Here Insert Picture Description

Material

New material, specify a color.
Here Insert Picture Description

Here Insert Picture Description
In the property there dragged
Here Insert Picture Description
then you might see is black, do not panic, add a light.
Here Insert Picture Description
Operation keys: hold the mouse mid-drag Alt-bit rotate the camera.
2D, 3D can click to switch
Here Insert Picture Description

Grain

Here I am on the Internet the way down a map
Here Insert Picture Description

Right assert a new material, selected mode, to check the map
Here Insert Picture Description
and then to the player node (Box)
Here Insert Picture Description

collision

3D physical impact yet, but there are 2D, our cool running in a plane, then with the original physical system can ah!
To add a rigid platform, the box collision, the collision component size was adjusted to 1, 1 (otherwise too)
Player box also note a static one is dynamic.
Here Insert Picture Description

New Script, simulate a jump

const {ccclass, property} = cc._decorator;

@ccclass
export default class Test extends cc.Component {

    @property(cc.Node) player: cc.Node = null;

    onLoad () {
        let p = cc.director.getPhysicsManager();
        p.enabled = true;
    }

    start () {
        this.scheduleOnce(() => {
            // 3秒后模拟跳跃
            let v = this.player.getComponent(cc.RigidBody).linearVelocity;
            v.x += 300;
            v.y += 200;
            this.player.getComponent(cc.RigidBody).linearVelocity = v;
        }, 3);
    }

    // update (dt) {}
}

How, there is no urge to do a physical 3D parkour game!
O (∩_∩) O ~~

Add my blog :( QQ group inside the project, the group has a file oh)
706 176 551
We learn together!
O (∩_∩) O ~~

Guess you like

Origin blog.csdn.net/kuokuo666/article/details/97944894