Physics object orientation left/right

For questions about using Classic.

Post » Sun May 31, 2009 5:22 am

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
and as a hybrid, Inherit the Wind

Select character - arrow keys
Continue - enter
Movement/jumping - arrow keys
Double jump - up again
Fire projectile - Control(right)
Special attack(Inherit the wind) - Num0
Return to menu - Esc

Select character - WASD
Continue - Enter
Movement/jumping - WASD
Double jump - W again
Fire projectile - Control(left)
Return to menu - Esc
Posts: 17
Reputation: 884

Post » Sun May 31, 2009 7:23 am

for the physics,

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 :
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
single left right value:
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:
so that next tick, lastx and lasty will always equal the previous ticks x and y values
Spriter Dev
Posts: 3,256
Reputation: 16,813

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests