playcanvas / playcanvas/engine

Raycast returns always null on first frame [AMMO]

Open
#4,231 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: physics
Dominant language
JavaScript
Stars
16.8k
Forks
2k
Avg merge
4h 32m
Merged PRs (30d)
222

Description

Reproduced

var Main = pc.createScript('main');

// initialize code called once per entity
Main.prototype.initialize = function() {
    this._box = this.app.assets.find("Box", "template").resource.instantiate();
};

Main.prototype.postInitialize = function(){

    this.box1 = this._box.clone();
    this.app.root.addChild(this.box1);
    this.box1.setPosition(0, 0.5, 0);

    
    this.box2 = this._box.clone();
    this.app.root.addChild(this.box2);
    this.box2.setPosition(3, 0.5, 0);


    const from = this.box1.getPosition();
    const to = this.box2.getPosition();
    console.log(this.app.systems.rigidbody.raycastFirst(from, to));
};

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue using the provided Main script and its postInitialize entry point. Start by tracing this.app.systems.rigidbody.raycastFirst(from, to) and the first-frame initialization sequence. Done means the initial raycast returns the expected hit rather than null.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.