Linear sound and velocity issue

colandercolander Member Posts: 1,610
I need some help with sound and motion. I am using the Windows version and i have created a rule to play a sound if self.motion.linearVelocity.x is > 1. This is fine while the actor moves from left to right however when it moves the other way the sound won't play.

I have searched the forum and from what I can see this is correct.

Best Answer

  • gyroscopegyroscope I am here.Posts: 6,598
    edited August 2013 Accepted Answer

    Hi @colander

    For the actor moving right to left, use When self.motion.linearVelocity.x is < 0 (or -1).

Answers

  • colandercolander Member Posts: 1,610
    Thanks gyroscope I had tried that with two attributes in my rule one > 1 and the other < -1 and it didn't work. But your answer let me know I was on the right track so I went back and looked harder at what I had done. I found I hadn't changed All to Any in my rule, duh rookie mistake.
  • ericzingelerericzingeler Member Posts: 334
    edited August 2013
    Sounds like you want to use speed and not velocity. Like so:

    attribute:

    speedTrigger = 1

    rule type 1 (x plane only):

    if speedTrigger < abs(motionLinearVelocity.x)

    rule type 2 (x and y plane):

    if speedTrigger < magnitude(motionLinearVelocity.x , motionLinearVelocity.y)

    Velocity is not speed, but instead a vector quantity. Go here for the difference:

    http://www.physicsclassroom.com/class/1dkin/u1l1d.cfm
  • colandercolander Member Posts: 1,610
    Thanks Eric that works better. Using velocity I needed two rules because I also have a collision condition. Now I only need one rule to achieve the same thing.

    A further question how can I get the sound to change as an object changes speed i.e rolling up and down hills?
Sign In or Register to comment.