HomePortalFAQSearchMemberlistUsergroupsRegisterLog in
Making threads to link to banned members content grants an automatic ban
Meet the new KITO admins & hear their plans here.
You can use google search to find threads and posts here now. Example

Share | 
 

 Attack problem

View previous topic View next topic Go down 
AuthorMessage
Gingerlove

avatar

Posts : 15
Join date : 2015-09-16

PostSubject: Attack problem   Thu Oct 01, 2015 4:01 am

When my character attacks (backflip) it jumps too high!
I changed gravity (because the jump glitched, was too low) to:

#define FRICTION 3
#define GRAVITY 0.9
#define JUMP_ACCEL 0.3
#define TERMINAL_VEL 800
#define GROUND_THRESHOLD 2

Also when I attack the animal fly way too high, I searched a bit and haven't been able to fix it, any ideas? Please ><
Back to top Go down
Claire
Very Helpful
Very Helpful
avatar

Game username : SoftMoon | MissDiealot
Server : Vaellerios (admin) | Lair of the Wolf (admin) | Journey Kingdom (dev)
Female Posts : 326
Join date : 2015-03-03
Age : 16

PostSubject: Re: Attack problem   Thu Oct 01, 2015 2:38 pm

http://www.kitopen.com/t3569-how-do-i-change-back-the-gravity-solved
Search button is your friend, or just looking in the solved support section.
Back to top Go down
http://missdiealot.deviantart.com/
Gingerlove

avatar

Posts : 15
Join date : 2015-09-16

PostSubject: Re: Attack problem   Sat Oct 03, 2015 12:20 am

Softie wrote:
http://www.kitopen.com/t3569-how-do-i-change-back-the-gravity-solved
Search button is your friend, or just looking in the solved support section.
Actually I followed that, but it seems it did not worked this is why I decided to ask, I always search before asking, if I can't I ask ><.
Back to top Go down
Hyper
Admin
avatar

Game username : Hyper
Server : Azoptaos
Male Posts : 486
Join date : 2014-02-09
Age : 19

PostSubject: Re: Attack problem   Sat Oct 03, 2015 1:22 am

"it did not work" doesn't give us much to help you with

we need errors or specifics. if you followed that you wouldn't be back where you started - you'd have some sort of change, probably some sort of error if it isn't working correctly

________________________________
Back to top Go down
http://azoptaos.boards.net/
Gingerlove

avatar

Posts : 15
Join date : 2015-09-16

PostSubject: Re: Attack problem   Sat Oct 03, 2015 5:18 am

Oki, here I will send what I got.

Magix Object
Code:
#define FRICTION 3
#define GRAVITY 4
#define JUMP_ACCEL 0.3
#define TERMINAL_VEL 200
#define GROUND_THRESHOLD 2

Magix Player cpp
Code:
/*if (jump && distanceFromGround()<(MAX_JUMPHEIGHT*hasDoubleJumped ? 2 : 1) && mForce.y >= 0)
 addForce(Vector3(0, JUMP_GRAVITY*evt.timeSinceLastFrame + (distanceFromGround() <= GROUND_THRESHOLD ? 2 : 0), 0));*/
 if (jump && distanceFromGround() == 0 && mForce.y >= 0)
 addForce(Vector3(0, JUMP_ACCEL, 0));

 //Doublejump recharge
 if (distanceFromGround() <= GROUND_THRESHOLD)
 {
 isReadyToDoubleJump = false;
 hasDoubleJumped = false;
 }

 if (ascend && antiGravity)addForce(Vector3(0, 5 * evt.timeSinceLastFrame, 0));
 else if (descend && antiGravity)addForce(Vector3(0, -5 * evt.timeSinceLastFrame, 0));

Magix Unit
Code:
//Jump
 if (jump && distanceFromGround()<(MAX_JUMPHEIGHT*hasDoubleJumped ? 2 : 1) && mForce.y >= 0)
 addForce(Vector3(0, GRAVITY*evt.timeSinceLastFrame + (distanceFromGround() <= GROUND_THRESHOLD ? 2 : 0), 0));
 //Doublejump
 addForce(Vector3(0, 5, 0));

MagixAnimated.cpp
Code:
void MagixAnimated::updatePhysics(const FrameEvent &evt)
{
 //Friction
 if (mForce.x != 0 || mForce.z != 0)
 {
 Vector2 tVect = Vector2(0, 0);
 if (mForce.x == 0)
 {
 tVect.y = FRICTION;
 }
 else if (mForce.z == 0)
 {
 tVect.x = FRICTION;
 }
 else
 {
 Radian tAngle = Math::ATan(Math::Abs(mForce.z) / Math::Abs(mForce.x));
 tVect.x = FRICTION * Math::Cos(tAngle);
 tVect.y = FRICTION * Math::Sin(tAngle);
 }
 if (Math::Abs(mForce.x)<tVect.x*evt.timeSinceLastFrame)mForce.x = 0;
 else mForce.x -= tVect.x * (mForce.x<0 ? -1 : 1) *evt.timeSinceLastFrame;
 if (Math::Abs(mForce.z)<tVect.y*evt.timeSinceLastFrame)mForce.z = 0;
 else mForce.z -= tVect.y * (mForce.z<0 ? -1 : 1) *evt.timeSinceLastFrame;
 }

 //Gravity
 if (!antiGravity && distanceFromGround()>0)
 {
 mForce.y -= GRAVITY *evt.timeSinceLastFrame;
 }
 //Air resistance
 else if (antiGravity)
 {
 if (mForce.y > 0)
 {
 mForce.y -= FRICTION *evt.timeSinceLastFrame;
 if (mForce.y<0)mForce.y = 0;
 }
 else if (mForce.y < 0)
 {
 mForce.y += FRICTION *evt.timeSinceLastFrame;
 if (mForce.y>0)mForce.y = 0;
 }
 }

 //Speed limit
 if (Vector2(mForce.x, mForce.z).squaredLength()>Math::Sqr(maxSpeed*speedMultiplier*evt.timeSinceLastFrame))
 {
 Radian tAngle = Math::ATan(Math::Abs(mForce.z) / Math::Abs(mForce.x));
 mForce.x = maxSpeed * speedMultiplier * (mForce.x<0 ? -1 : 1) * Math::Cos(tAngle) *evt.timeSinceLastFrame;
 mForce.z = maxSpeed * speedMultiplier * (mForce.z<0 ? -1 : 1) * Math::Sin(tAngle) *evt.timeSinceLastFrame;
 }
 //Terminal Velocity
 if (Math::Abs(mForce.y)>TERMINAL_VEL*evt.timeSinceLastFrame*(antiGravity ? 0.5 : 1))mForce.y = TERMINAL_VEL * (mForce.y<0 ? -1 : 1)*evt.timeSinceLastFrame*(antiGravity ? 0.5 : 1);

 //apply forces to node
 lastPosition = mObjectNode->getPosition();
 mObjectNode->translate(mForce);
 if (penaltyVelocity != Vector3::ZERO)
 {
 mObjectNode->translate(penaltyVelocity);
 penaltyVelocity = Vector3::ZERO;
 }

 //clip to ground level if below ground or within ground threshold
 if (!antiGravity && (distanceFromGround()<0 || (distanceFromGround() <= GROUND_THRESHOLD && mForce.y <= 0)))
 {
 mForce.y = 0;
 mObjectNode->setPosition(mObjectNode->getPosition().x, groundHeight, mObjectNode->getPosition().z);
 }
 else if (distanceFromGround()<0)
 {
 mObjectNode->setPosition(mObjectNode->getPosition().x, groundHeight, mObjectNode->getPosition().z);
 }
}
void MagixAnimated::addForce(const Vector3 &value)
{
 mForce += value;
 //printStack();
 DBOUT("++++addForce: mForce.y: " << mForce.y << std::endl);
 record = 0;

I also noticed no matter how many times I change the gravity to .2, 4 whatever number it is the same :/, I edited something wrong?
Also maybe soemthing on this got bad my build, now it says 1 fail, 2 success, the errors it puts are this:

Back to top Go down
 
Attack problem
View previous topic View next topic Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Keeping I.T. Open :: SUPPORT :: Support-
Jump to: