Energy Engine
Member
Hi,
I'm trying to get the pointing direction of an object to be in increments of 2. So whenever an object is facing a target, the direction value should be in multiples of 2. Essentially, only in even numbers, not odd numbers. Very similar to simply changing direction by having direction+=2. Problem is, I can't figure out how to get this to work with point_direction. Assume the object's target is the mouse.
Here is what I have:
Create:
Step:
This makes the object point towards the mouse, and produces dir values in factors of 1. How would I get the object to point at the mouse in factors of 2? I looked through the Real Numbers page in the manual, but since my math is horrendous, I couldn't recognize any function that would allow me to do this.
Thanks in advance!
I'm trying to get the pointing direction of an object to be in increments of 2. So whenever an object is facing a target, the direction value should be in multiples of 2. Essentially, only in even numbers, not odd numbers. Very similar to simply changing direction by having direction+=2. Problem is, I can't figure out how to get this to work with point_direction. Assume the object's target is the mouse.
Here is what I have:
Create:
Code:
threshold=4
dir = 90
starting_angle = 0//image_angle
ending_angle = 0//point_direction(x, y, mouse_x, mouse_y)
difference = angle_difference(ending_angle, starting_angle)
delta = min(abs(difference) / threshold, 1) * threshold * sign(difference)
Code:
starting_angle = dir
ending_angle = point_direction(x, y, mouse_x, mouse_y)
difference = angle_difference(ending_angle, starting_angle)
delta = floor(min(abs(difference) / threshold, 1) * threshold * sign(difference))
dir += delta
Thanks in advance!