Warp Theory

I have postulated that it is possible to create warp for my spaceship. Had a first go at creating it today.

My script is as such:

function init_warp(){

physics_apply_force(obj_Aura.x, obj_Aura.y,
x + lengthdir_x(500, image_angle), y + lengthdir_y(500, image_angle));
draw_sprite_stretched(obj_Aura, 0, obj_Aura.x, obj_Aura.y, 10, 30);

}
The way it is initialized is in the ship's step event with:

if keyboard_check(ord("V")) {
init_warp();
}

And here is the lovely error code:


___________________________________________
############################################################################################
ERROR in
action number 1
of Step Event0
for object obj_Aura:

The instance does not have an associated physics representation
at gml_Script_init_warp (line 5) - physics_apply_force(obj_Aura.x, obj_Aura.y,
############################################################################################
gml_Script_init_warp (line 5)
gml_Object_obj_Aura_Step_0 (line 47) - init_warp();
 

flyinian

Member
@KungFuChowder,

I don't know anything about the physics but, I think if you are trying to learn GML, then using physics is probably not a good way to go. That's a whole different beast to tackle.

However, I don't really know because I haven't touched physics before.
 

Roldy

Member
GML:
function init_warp(){


        physics_apply_force(obj_Aura.x, obj_Aura.y,

        x + lengthdir_x(500, image_angle), y + lengthdir_y(500, image_angle));

        draw_sprite_stretched(obj_Aura, 0, obj_Aura.x, obj_Aura.y, 10, 30);



}
As @flyinian suggests, you may want to take a step back. You have several error that suggest you may not have a solid understanding of GML.

To interact with the Box2D physiscs system you need to create and attach fixtures to your instances:

The draw_sprite_stretched function requires a sprite index and some coordinates:

However you are passing in an Object index instead of sprite index. As well you reference an Object for the x, y coordinates instead of a specific instance. You may want to study the difference between objects and instances of objects:
 
Top