How do I determine a value from an angle (radio tuner simulation) ?

0 favourites
  • 5 posts
From the Asset Store
Each style is designed to enhance immersive soundscapes, from dystopian worlds to nostalgic, vintage settings.
  • Hello,

    I'm trying to simulate a radio receiver.

    Here's how it works : the needle rotates around its axis. In the following image, theres a network broadcasting from the position where the red dot is (90°). When needle angle is 90°, volume is at its max (0 db). When needle moves away from 90° (ie to 85° or 95°, ie 90°±5°), volume decreases and reaches silence (-20) when 85° or 95° is reached.

    How can I do that ? I knwo angle math is involved but I have issues dealing with the "90°±5°" part.

    I even tried an approach using positionning sounds (using the blue dot as a receiver and red dot as a emitter) but it is not very flexible.

    Tagged:

  • Well in construct the red dot is at angle 0 from the center of the needle. You can then use the anglediff() expression to get the difference between two angles. And to make it -20 at five just multiply by -4

    Volume =-4* anglediff(0, needle.angle)

    Or if you just want to use the position of the red dot instead of an angle

    Volume = -4*anglediff(angle(needle.x,needle.y,red.x,red.y), needle.angle)

  • Wonderful ! Thank you very much.

    the first solution works very well but there seem to have a problem with the second where the comparison should maybe be made with angle between blue dot and red dot from the rotation center of the needle. What do you think ?

  • It should be the same.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • OK, I managed to have it working, +90 had to be added somewhere : -4*anglediff(angle(AiguilleRadio.x,AiguilleRadio.Y,emetteur.x,emetteur.y)+90, AiguilleRadio.angle)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)