Cannot read property 'applyForce' of undefined error in Cocos Creator

sequence:

        1. The blogger made the bug when watching this tutorial ===> Game Development | Learn how to use Cocos Creator to create a 3D parkour game in 17 lessons | P9 code to control object movement_bilibili_bilibili         2. In fact, the problem is not in the code, but it is found that the object does not translate

        3. Node full stack information ==》node full stack framework

text:

       1. You must first configure the same configuration as the blogger. The blogger’s ts

import { _decorator, Component, Node ,RigidBody, Vec3} from 'cc';
const { ccclass, property } = _decorator;

@ccclass('PlayerMovement')
export class PlayerMovement extends Component {
    @property(RigidBody)
    rigidBody:RigidBody
    start() {
        let force=new Vec3(0,0,500);
        this.rigidBody.applyForce(force);
    }

    update(deltaTime: number) {
       
    }
}

        2. Come on, let’s see if you have selected your Player node. The capitalization must be correct. Most people do not select the reverse selection here. What they mean is to specify which node, otherwise this will be null.

         3. See if the current scene is selected here

 Okay, let’s see if you can use it. The blog post is original. I really want to thank the blogger. You can go to blogger gzh and follow it: ==》 Is the web front-end dead? The truth is out.

Guess you like

Origin blog.csdn.net/xuelang532777032/article/details/132121718
Recommended