actors (A), (B) question please help

nCartoonnCartoon Member, PRO Posts: 54
I have a question
I have 2 actors (A), (B) how can I write a code to be like this
- if actor (A) heading to actor (B) "Opposite direction" at 400 Speed
then actor (B) destroy

-if actor (A) and (B) are moving "same direction" but (A) is 400 Speeder
then actor (B) destroy

-if actor (A) heading to actor (B) "actor (B) is not moving" at 400 Speed
then actor (B) destroy

Comments

  • contrasthallcontrasthall Member Posts: 131
    i think look up magnitude..it would be easy to do based on a x and y attributes....but then again I'm not exactly sure what this is for and u could have a sneaky glitch or two that could drive u nuts if angles are involved.
  • VoidedSkyVoidedSky Member Posts: 1,095
    @contrasthall is right. You can us the magnitude function. You will have to constrain both the actors' positions to global real attributes, or juat access their positions through unlocked prototypes. Make a local(in an actor) attribute called distance. This will be 400 or whatever diatance you want it to be. Then you make a rule that says: "when self distance is < magnitude(otherActorPositionX,otherActorPositionY) then: destroy


    That is the basic structure of what you will need to do. Hope this helps!


    ~Josh
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Pretty sure @Ncartoon is not wanting to measure distance, but direction. If that's the case, look up vectorToAngle: http://forums.gamesalad.com/discussion/33831/vectortoangle-explanation

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • nCartoonnCartoon Member, PRO Posts: 54
    Ok I will make my question easier
    I have one actor (A)
    if actor (A) going to right then true or false etc.....

    Is there direction determines of an actor ?
  • VoidedSkyVoidedSky Member Posts: 1,095
    If self.linearVelocity is < 0: change self.direction to 2, otherwise change self.direction to 1.

    2 is left. 1 is right.

    Hope that helps

    ~Josh
  • nCartoonnCartoon Member, PRO Posts: 54
    Thank you VoidedSky for help but I did it my own way I used faceRight true of false and it's works with me I just want it for my Super Mario template and It's done and published in the YouTube
    again thank you guys :)
  • FrankdevFrankdev Member Posts: 1
    I've looked at vecterToAngle a bit.
    Doesn't aTan(y/x) do exactly the same as vectorToAngle(x,y)
    I've tested both and the aTan works a little better for me, with more consistent results.
  • SocksSocks London, UK.Member Posts: 12,822
    edited February 2013
    I've looked at vecterToAngle a bit.
    Doesn't aTan(y/x) do exactly the same as vectorToAngle(x,y)
    I've tested both and the aTan works a little better for me, with more consistent results.

    Yeah, but VectorToAngle sounds cooler, it's got the word 'Vector' in for god's sake, it sounds like a 1970's sci-fi robot or something.

    The Professor (watching from his helicopter as 'Vector' destroys NewYork): "Oh my god, you fools, you've given it eyes, I told you not to give it eyes"
Sign In or Register to comment.