Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node with 2D Collider is not sync when it positionned before changing the parent node #15805

Closed
BenoitFreslon opened this issue Jul 22, 2023 · 6 comments
Assignees
Milestone

Comments

@BenoitFreslon
Copy link

Cocos Creator version

3.7.3

System information

Windows 11

Issue description

When a prefab is instanciated, if the parent is set before the position of a 2D collider, the collider doesn't move after the instanciation of the prefab. Box2D physic engine.

image

Relevant error log output

No response

Steps to reproduce

        const sun: Node = instantiate(this.sunPrefab);
        // Random position
        const x = Math.random() * 100;
        const y = Math.random() * 100;
        sun.parent = find("Canvas");
        sun.position = new Vec3(x, y, 0);

Minimal reproduction project

No response

@BenoitFreslon BenoitFreslon added Bug Needs Triage Needs to be assigned by the team labels Jul 22, 2023
@pandamicro pandamicro added Module: Physics and removed Needs Triage Needs to be assigned by the team labels Aug 3, 2023
@pandamicro pandamicro added this to the V3.8.1 milestone Aug 3, 2023
@joshi-cse-4000
Copy link

Yes same issue happening with me. The collider doesn't move while i drag and drop any workaround for this ?

@minggo minggo assigned minggo and unassigned lealzhan Oct 19, 2023
@minggo minggo modified the milestones: V3.8.1, v3.8.3 Dec 5, 2023
@minggo
Copy link
Contributor

minggo commented Dec 27, 2023

@BenoitFreslon could you please provide a demo? What's sunPrefab ?

@minggo
Copy link
Contributor

minggo commented Dec 27, 2023

the collider doesn't move

What does it mean?

@BenoitFreslon
Copy link
Author

I think I can't reproduce this bug in CC 3.8.1

@minggo
Copy link
Contributor

minggo commented Jan 2, 2024

Ok, i will close this issue. Please reopen it if it still has problem.

@minggo minggo closed this as completed Jan 2, 2024
@fahrettinenes
Copy link

I also get the same problem on a hobby-project.
image

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

@ccclass('PipeController')
export class PipeController extends Component {
    start() {

    }

    update(deltaTime: number) {
        this.node.position = new Vec3(this.node.position.x - 1, this.node.position.y, this.node.position.z)
    }
}

PipeController is attached for each Pipe Node.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants