Physics object orientation left/right

This forum is currently in read-only mode.
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • Hello all. I'm working with a multiplayer game, a parody on Super Smash Brothers, involving a few physics-object lobbing characters. Because they throw physics objects, which (I think) don't have a set left(180) right(0) orientation, I run into a problem with pushback.

    My problem is that I wish to make the player on the receiving end of the objects get smacked in the related direction. The smacking distance and such I have down, but what I can't figure out is how to allow the pushback events to determine the movement direction (left/right) of a family called 'Projectiles'.

    To note: The 'Projectile' family is comprised of bullets, physics objects, and one hybrid.

    Here's a quick exe. Characters with parabolic (physics object) attacks are:

    Mice and Men

    The Crucible

    Cuckoo's Nest

    Beowulf

    and as a hybrid, Inherit the Wind

    http://dl.getdropbox.com/u/676998/Earlytest.exe

    P1

    Menu

    Select character - arrow keys

    Continue - enter

    Game

    Movement/jumping - arrow keys

    Double jump - up again

    Fire projectile - Control(right)

    Special attack(Inherit the wind) - Num0

    Return to menu - Esc

    P2

    Menu

    Select character - WASD

    Continue - Enter

    Game

    Movement/jumping - WASD

    Double jump - W again

    Fire projectile - Control(left)

    Return to menu - Esc

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • for the physics,

    Sprite[Physics].VelocityX[/code:1n72dx8u]
    this is an expression under the 'physics' tab when you double click your sprite
    and will return the left and or right speed of your object
    if Sprite[Physics].VelocityX is less than 0 it's going left, and if it's greater than 0 it's going to the right
    
    if you only want a simple left or right value:
    direction will be either -1 for left, 0 for not moving, or 1 for right if you :
    [code:1n72dx8u]
    direction = Sprite[Physics].VelocityX/abs(Sprite[Physics].VelocityX)[/code:1n72dx8u]
    abs is found under the system object and is the absolute value function 
    
    if you want more than just left or right and you want the actual angle it's moving at, that is also possible:
    [code:1n72dx8u]angle(0, 0, Sprite[Physics].VelocityX, Sprite[Physics].VelocityY)[/code:1n72dx8u]
    
    with bullet it would be the same thing, but with Sprite[Bullet].VectorX, etc instead of Sprite[Physics].VelocityX
    
    if you need the family to be both bullets and physics, there is a messier way to do it:
    
    make each object have a private variable LastX that gets set to the current x value at the end of each tick
    
    for left and right
    [code:1n72dx8u]LeftorRightness=sprite('LastX')-Sprite.x[/code:1n72dx8u]
    single left right value:
    [code:1n72dx8u]Xdirection=abs(sprite('LastX')-Sprite.x)/(sprite('LastX')-Sprite.x)[/code:1n72dx8u]
    for exact angle 
    [code:1n72dx8u]anglemovingat = angle(sprite('LastX'), sprite('LastY'), Sprite.X, Sprite.Y)[/code:1n72dx8u]
    the last action after getting this info should be:
    [code:1n72dx8u]sprite('LastX')=Sprite.X
    sprite('LastY')=Sprite.Y[/code:1n72dx8u]
    so that next tick, lastx and lasty will always equal the previous ticks x and y values
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)