Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Jump Problem

Author
Message
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 18th Dec 2014 21:12 Edited at: 18th Dec 2014 21:54
Hi.

I wrote a code that the Player can jump once when SPACE key is Pressed. for this work I checked if sprY = 90 then Player can jump that work very well.
but there is a Problem that always sprY is not 90 when put on the other grounds.

this is my full code:



another way is check all grounds that Player is on them and change jump to 0 and 1. but I think should there is better way.

Please Guide Me.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 18th Dec 2014 21:29
u need something that say "at ground" or "in air".
u can jump only from ground.
also look at SetSpritePhysicsImpulse

AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 18th Dec 2014 21:53 Edited at: 18th Dec 2014 21:53
Quote: "u need something that say "at ground" or "in air".
u can jump only from ground."


i said at first post that (another way is check all grounds that Player is on them and change jump to 0 and 1).

I want know should use up way for check the Player is on the ground or no? because should check each collision between Player and ground.it's correct?

Quote: "also look at SetSpritePhysicsImpulse"


use this Function seem no have good result for jump because if press once more SPACE key, before player collide to ground can jump Times at air.
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 19th Dec 2014 00:29
You could check for collision below the players usual Y position. Like, make a floor from sprites with collision enabled, add platforms too of course, and get your collision working with that, even if there is no working jump function. Ideally, you'd be able to start the player on top of a platform, and make sure they can walk left and right and drop down to the floor.

Once you have that, you could check for a ray collision at the players feet, or like the X Y position of the player, down to the bottom of the sprite plus a little more. If there is a collision with the ray check, then it means the player is standing on solid ground, no matter what the height. If you only allow the player to jump when the ray collision is true, then they will only be able to jump from solid ground, and it will fix that double-triple-jump issue as well. If you actually want a double jump, then you could just have a flag that resets to 0 if the player is on solid ground, then when they jump, set it to 1, and if they jump again and the flag is at 1, let them jump no matter what they're standing on, then set the flag to 2. Personally, I think that double-jumps add a bit of freedom to the game, as the platform layout doesn't have to be so exact, and it's easy to introduce bonus areas that need a bit of thought and skill to get to... like a coin that is just too high up to get at with a normal jump.

I think a wise thing to do is get those platforms in place so you aren't relying on Y>90 - look into setting the sprites into collision groups, as that is a must, and adapt things as much as you can before adding the jump handling - it should be quite straightforward once you have player collision against platforms in place.

I am the one who knocks...
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 19th Dec 2014 10:52
Thanks VanB.

but how can use "SpriteRayCast ( x, y, x2, y2 )" for dynamic Objects?(e.g: Player that no have const position).

and how see where is RayCast place like "SetPhysicsDebugOn()"?
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 19th Dec 2014 13:11
Ray cast checks can be fiddly, I usually just print the collision state so I can see what it's doing, and make adjustments until its right. Ray cast checks don't show up on physics debug mode, but you could draw a line for example.

I think that you will have to take control over physics velocities, so when doing that, store the position of the player sprite for the ray collision check. You could store the position and the X Y velocity, and apply the movement and jumping to the stored velocity then set them back to the player sprite. The prescribed method is to use physics impulses, however I tend not to have much luck getting things working exactly as I like, so tend to just override the physics where I need to. Doing it this way rather than using a dynamic sprite (one that you control rather than being subject to physics) means that it will still respond to external collisions - the player sprite would be knocked back if hit by a physics sprite for example.

I am the one who knocks...
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 19th Dec 2014 13:45
I only understand this par of your say.

Quote: "
Ray cast checks can be fiddly, I usually just print the collision state so I can see what it's doing, and make adjustments until its right. Ray cast checks don't show up on physics debug mode, but you could draw a line for example."
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 19th Dec 2014 14:13
u can set also a dummy sprite below foot as sensor.
SetSpritePhysicsIsSensor

AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 19th Dec 2014 14:43 Edited at: 19th Dec 2014 15:20
Quote: "u can set also a dummy sprite below foot as sensor."


seem good idea. but how can check SetSpritePhysicsIsSensor for collision? like said at first post should check dummy collision between other grounds?
how can joint dummy sprite below foot? because for joint two sprite together should dummy sprite have a Physics.while dummy sprite should no have Physics. how can do it?
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 19th Dec 2014 15:59
Hi

Another simple way to do what you want :

IF you create an array of block, you have to test all the blocks to see if there is a collision between the player and one of the block.



http://www.dracaena-studio.com
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 19th Dec 2014 16:11
Hi Blendman and Thanks for your help.

but my sprites no have array. and my Sprite Y always not 90.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 20th Dec 2014 10:04
copy it her too because belongs the thread


AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 20th Dec 2014 11:56
Thanks Markus for Your example.

I check it.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 21st Dec 2014 13:55
Thanks Markus work very well.
World Class Multimedia
16
Years of Service
User Offline
Joined: 15th Aug 2008
Location: Florida, USA
Posted: 26th Dec 2014 17:49
I am creating a 3D character controller for 1st and 3rd person AGK2 games both for desktop and mobile. Desktop utilizes mouse, joystick or keyboard and mobile utilizes virtual joysticks and buttons. I may utilize using the tilt feature of mobile devices but I've never been a fan of using accelerometers.

I am having trouble with jumping. I created a virtual button marked jump and altered the Y direction of the player when pressed, but that did not work.

I have movement and rotation working.

I also will be working on running, climbing, jet pack and swimming as well.

Any advice on getting jumping to work? I'm on mobile, so no code fragment to give right now. I'll reply to this with my code fragment when I get home.

YOU DREAM IT - WE CREATE IT!
www.world-class-multimedia.com
For world-class virtual instruments - www.supersynths.com

Login to post a reply

Server time is: 2024-11-25 15:03:54
Your offset time is: 2024-11-25 15:03:54