Type mismatch in example
Im trying to learn how to use the crate by following the collision pipeline example.
However, the following line, as it appears in the example, seems to no longer compile:
// Integrate the positions.
ball_pos = ball_object.position.append_translation(&(timestep * ball_velocity.get()));
Fails with
note: expected type `&nalgebra::TranslationBase<f32, nalgebra::U2, nalgebra::MatrixArray<f32, nalgebra::U2, nalgebra::U1>>`
found type `&nalgebra::Matrix<f32, nalgebra::U2, nalgebra::U1, nalgebra::MatrixArray<f32, nalgebra::U2, nalgebra::U1>>`
Does anyone know how to fix this?
The documentation seems to be out-of-date. This should be:
ball_pos = ball_object.position.append_translation(&Translation::from_vector(timestep * ball_velocity.get()));
Thank you very much :)
It compiled after using your code with an extra unwrap, as from_vector returns an Option.
Now I've got a runtime error five lines above it:
// Integrate the velocities.
let ball_object = world.collision_object(8).unwrap();
panics as it's unwrapping None.
Any idea what that might be?
Did you keep the following line fom the example ?
// Add the ball to the world.
world.deferred_add(8, ball_pos, ball, ball_groups, GeometricQueryType::Contacts(0.0), ball_data);
ncollide identifies objects with user-supplied integers. world.collision_object(8) returning None means that no object whith the ID 8 has been added before.
Yup, got it exactly as is. The other identifiers return None as well.
This is my entire code, but apart from the Translation::from_vector and the extern crate uses it's just copy pasted from the example.
I found the problem!
It works if right after
// Add the ball to the world.
world.deferred_add(8, ball_pos, ball, ball_groups, GeometricQueryType::Contacts(0.0), ball_data);
we use
world.update()
Although I have to ask if this behavior is intentional or a bug.