ratalaika / angel-engine

Automatically exported from code.google.com/p/angel-engine
0 stars 0 forks source link

SetUserData makes SetLinearVelocity not work #72

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. making physicsActor move with SetLinearVelocity
2. set userdata to the body
3.

What is the expected output? What do you see instead?
actor moves and its body contains own bitmask data
instead the actor is not moving anymore...(he was before calling SetUserData)

What version of the product are you using? On what operating system? Is it
a downloaded distribution or from SVN?
Win 7, Angel-3.0.1, dw

Please provide any additional information below.
I want to move my character with the arrow keys and have it contain my own 
bitmask somehow

Original issue reported on code.google.com by maliusa...@gmail.com on 3 Jan 2013 at 5:52

GoogleCodeExporter commented 9 years ago
I'm not entirely clear on what's going wrong here -- do you have some example 
code that reproduces the problem? 

Original comment by lieseg...@gmail.com on 4 Jan 2013 at 5:37

GoogleCodeExporter commented 9 years ago
void ScreenTest::Start()
{
    m_sky = new CloudActor("Resources/Images/clouds2.jpg", "Sky"); //derived from Actor
    m_ground = new GroundActor("Resources/Images/floating1.png"); //derived from Actor
    m_arth = new CharActor(GetBitmask("Resources/Images/animations/chars/arth/arthBitmask.png")); //derived from PhysicsActor

    if(m_arth->GetBody() != NULL){
        m_arth->GetBody()->SetUserData((void*)m_arth->GetMask());
        std::cout << "data: " << static_cast<Bitmask*>(m_arth->GetBody()->GetUserData())->getPath() << std::endl;
    }
    //theWorld.BeginContact();

    theWorld.Add(m_arth, "Front");
    theWorld.Add(m_ground);
    theWorld.Add(m_sky);

    //Game housekeeping below this point. 
    #pragma region Game Housekeeping
    _objects.push_back(m_sky);
    _objects.push_back(m_ground);
    _objects.push_back(m_arth);
    #pragma endregion
}

the code above is the essential part but I've attached the real file
the std::cout seems to be correct but after a seconds or so I get a 
std::length_error now...

Original comment by maliusa...@gmail.com on 6 Jan 2013 at 4:19

Attachments:

GoogleCodeExporter commented 9 years ago
The body's userdata needs to be the Angel actor that it's tied to. That's how 
it receives draw updates from the engine itself. You shouldn't change the 
physics body's userdata. If you need to store extra data for an actor, you can 
store it on the actor itself. 

Original comment by lieseg...@gmail.com on 6 Jan 2013 at 8:13

GoogleCodeExporter commented 9 years ago
can i set the userdata to point at a class derived from physicsactor, then?

Original comment by maliusa...@gmail.com on 7 Jan 2013 at 2:26

GoogleCodeExporter commented 9 years ago
If you derive a class from PhysicsActor, the userdata will already be pointing 
at it as its set during PhysicsActor's constructor. 

Original comment by lieseg...@gmail.com on 7 Jan 2013 at 3:47

GoogleCodeExporter commented 9 years ago
great thanks

Original comment by maliusa...@gmail.com on 7 Jan 2013 at 3:49