Object Variable - Angle

Questions, comments and discussion about the Game Editor development.

Object Variable - Angle

Postby bamby1983 » Mon Dec 31, 2012 11:07 pm

The game editor script reference defines the angle variable as follows:

angle: Move the Actor's angle (0 to 360, from the positive x axis, counterclockwise, in degrees).


I cannot seem to find any example code for this and what it does. Is this an object variable on the lines of xscreen and yscreen and can it be used to modify the rotational angle of an animation?
bamby1983
 
Posts: 112
Joined: Tue Jul 31, 2012 11:36 pm
Score: 8 Give a positive score

Re: Object Variable - Angle

Postby Hblade » Tue Jan 01, 2013 1:31 am

An example code:
Using angle with directional_velocity
Code: Select all
angle=direction(x, y, actor.x, actor.y);
directional_velocity=5;


This will move to an actor at a velocity of 5. You can also "ease in/out" to an actor by using directional_velocity=distance(x, y, actor.x, actor.y)/2;.
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Object Variable - Angle

Postby bamby1983 » Tue Jan 01, 2013 7:28 am

Hblade wrote:An example code:
Using angle with directional_velocity
Code: Select all
angle=direction(x, y, actor.x, actor.y);
directional_velocity=5;


This will move to an actor at a velocity of 5. You can also "ease in/out" to an actor by using directional_velocity=distance(x, y, actor.x, actor.y)/2;.


Thanks for the explanation. I'm still not sure as to what the "angle" variable does, though, and how it is different from any user defined variable. I mean if this is a standard in-game variable, then what does it affect? Does it rotate an object or just store the value of direction(x, y, actor.x, actor.y) like any user defined variable would do?

Can this angle variable be used specific to a particular actor (eg., MyActor.angle)?
bamby1983
 
Posts: 112
Joined: Tue Jul 31, 2012 11:36 pm
Score: 8 Give a positive score

Re: Object Variable - Angle

Postby Hblade » Tue Jan 01, 2013 7:58 am

bamby1983 wrote:
Hblade wrote:An example code:
Using angle with directional_velocity
Code: Select all
angle=direction(x, y, actor.x, actor.y);
directional_velocity=5;


This will move to an actor at a velocity of 5. You can also "ease in/out" to an actor by using directional_velocity=distance(x, y, actor.x, actor.y)/2;.


Thanks for the explanation. I'm still not sure as to what the "angle" variable does, though, and how it is different from any user defined variable. I mean if this is a standard in-game variable, then what does it affect? Does it rotate an object or just store the value of direction(x, y, actor.x, actor.y) like any user defined variable would do?

Can this angle variable be used specific to a particular actor (eg., MyActor.angle)?


Angle sets the directional_velocity direction. Example if you say angle=45; then directional_velocity=5; the actor will move at a 45 degree angle.

And yes it can I believe, MyActor.angle should work

Using the code I gave you, you can calculate the angle you are from that other actor Example the player is in the center, and you want to calculate the angle between/to/from the player, this code would do that
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Object Variable - Angle

Postby skydereign » Tue Jan 01, 2013 8:11 am

bamby1983 wrote:
Hblade wrote:An example code:
Using angle with directional_velocity
Code: Select all
angle=direction(x, y, actor.x, actor.y);
directional_velocity=5;


This will move to an actor at a velocity of 5. You can also "ease in/out" to an actor by using directional_velocity=distance(x, y, actor.x, actor.y)/2;.


Thanks for the explanation. I'm still not sure as to what the "angle" variable does, though, and how it is different from any user defined variable. I mean if this is a standard in-game variable, then what does it affect? Does it rotate an object or just store the value of direction(x, y, actor.x, actor.y) like any user defined variable would do?

Can this angle variable be used specific to a particular actor (eg., MyActor.angle)?

angle is an actor variable. Any actor variable can be obtained through means like MyActor.var. The script reference has the list of all built into gE (except pathxpos/pathypos). One thing to watch out for, is that the value of angle becomes 0 when the actor stops moving. This is similar to the velocity variables. So, to prevent this, you would either need to create your own angle variable, or have directional_velocity set to non-zero values.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron