GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2012-11-23 15:51:24

Boysano
Member
Registered: 2012-11-14
Posts: 4

phy_look_to(target_object)

I already submitted, but this can help now already if you want to know how to easily rotate object to look towards other objects in the physics world of GMS, since direction and image_angle doesnt work anymore.

Very handy for homing missiles, or space ships following other ships, etc.

Expand//phy_look_at(target);
//This script will make physical object rotate always to look at another target object in physics world
//script should be in STEP event
//returns = noone
{
var target, dir;

target = argument0;

    if instance_exists(target) {
        dir = point_direction(x,y,target.x, target.y);
    }
    else {
    exit;
    }
   phy_rotation = -(dir-90);    
}

Last edited by Boysano (2012-11-23 15:53:36)

Offline

#2 2012-11-23 20:11:05

icuurd12b42
Member
Registered: 2008-12-11
Posts: 303

Re: phy_look_to(target_object)

Good. You should add a script that does the reverse and perhaps a versions that takes angle as argument gm_angle_to_phy_rotation(gmangle)
phy_rotation_to_gm_angle(phyrot)

Offline

Board footer

Powered by FluxBB