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.

Newcomers DBPro Corner / Need help with camera following character

Author
Message
Sazex
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location:
Posted: 4th Jan 2012 01:57
Thanks Nonzero, that was the problem just changed it back to inc number_of_jumps,

Ok so know all I have to do is have the player not be able to jump after number_of_jumps = max_number-of_jumps..

Oh and hodgey, I did the sc_drawobjectbounds, and well, do you know if is it going to affect the object collision?

sazex
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 4th Jan 2012 02:07
Btw how about placing ceilings? Invisible of course...

Sazex
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location:
Posted: 4th Jan 2012 02:18 Edited at: 13th Jan 2012 07:27
I could, but I would still need my character to fall, otherwise the player could just keep pressing spacebar and cling to the ceiling

anyways I have yet another dilemma, by changing it to inc number_of_jumps, my character again only jumps twice and stops being able to jump, here is my entire code now:



sazex
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 4th Jan 2012 08:34
Quote: "Oh and hodgey, I did the sc_drawobjectbounds, and well, do you know if is it going to affect the object collision?
"

Sorry, I can't make sense of it. I printed the collision and it returned 0 while clearly walking though a polygon of the collision shape. I'm afraid my experience with sparky's collision is rather limited.

Sazex
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location:
Posted: 4th Jan 2012 09:18 Edited at: 4th Jan 2012 09:21
Hmm, does DarkPhysics handle good collision? Because I recently bought it and the whole Bonanza pack

Alsoo while I'm asking questions, does anyone know how to get an animation of a character to override another animation here's what I mean:
I have a certain animation for when I press "w"
and have another one for If I press "shift" and
"w" but the problem is since I already have an
animation for w, the game does not play the
animation for shift and w, but instead only
plays the first frame of the shift and w
animation,(when I press shift and w that is)
does anyone know how to fix this?

sazex
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 4th Jan 2012 22:24
maybe try running a condition inside your "IF w was pressed" condition.

....more or less.

Sazex
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location:
Posted: 5th Jan 2012 04:45 Edited at: 5th Jan 2012 04:55
Din't work
but anyways thats a side problem, the main problem I'm having is the double jumping

OK so I believe Im almost done with the jumping thing, all I have to do is finish this code



and what I want to do there is make it so that my character falls to the ground when that condition is met, or something along those lines, such as perhaps disabling spacekey, until the ground is hit?

sazex
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 5th Jan 2012 16:28
Quote: "
"


That'll reset your jump count the minute you reach your limit. Also,

Quote: "Din't work"


Copy this, paste it into a new file and run



It works fine. Perhaps you need to centralise your animation handling. Try constructing your code so your only need to call LOOP OBJECT once, ie setting your frames in your IFs instead of calling LOOP OBJECT each time:



Moving on to jumping again, if your collision isn't detecting when you hit the ground, then it's a collision problem. It should be straight forward. If your jumps are > 0 then check your collision with the ground. If that comes back true, [optionally check player distance from ground to prevent errors during takeoff, IF your initial velocity doesn't move you out of the collision box on the first cycle] reset number_of_jumps to 0.

On making your character fall, you've got a sort of self timer since you're using gravity and velocity so he'll fall on his own. By placing number_of_jumps < 2 condition before the keycheck for space, the player cannot jump after exhausting his limit.

Sazex
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location:
Posted: 6th Jan 2012 01:37
Quote: "On making your character fall, you've got a sort of self timer since you're using gravity and velocity so he'll fall on his own. By placing number_of_jumps < 2 condition before the keycheck for space, the player cannot jump after exhausting his limit."


I get that but the problem Im having is defining this:
Quote: "the player cannot jump after exhausting his limit"
\
how do I tell my program that the player cant jump anymore?

Quote: "It works fine. Perhaps you need to centralise your animation handling. Try constructing your code so your only need to call LOOP OBJECT once, ie setting your frames in your IFs instead of calling LOOP OBJECT each time:"


Does defining variables for the numbers really change the outcome?

and I did this,


^ and that did not work, maybe I'm doing something wrong, I put the code on the top of everything to make sure it had priority... with no results... of course...

anywho, just in case, to try to make it more clear, the problem I'm having with the animations is that the game screws up when I have two animations for the same button (one of course has shift with it)

sazex
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 6th Jan 2012 02:24
Ok Sazex, try this:



This works for me quite well.

I don't know how to get ontop of a building so could you test that part?

Sazex
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location:
Posted: 6th Jan 2012 02:47
YES! finally, it works! thank you Hodgey!
Oh and to get him on the top of the roof tops i just put max jumps to three and got him on top

anyways now thats finally fixed, I can continue with the next part I was working on which was the animations, so before I finish up I just wanted to know if anyone knows how to fix my problem with the animation I was having

this is the problem ive been having:
Quote: "anywho, just in case, to try to make it more clear, the problem I'm having with the animations is that the game screws up when I have two animations for the same button (one of course has shift with it)"


sazex
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 6th Jan 2012 03:09
Quote: "YES! finally, it works! thank you Hodgey!"

That's good, I feel just as happy as you do!

If you'd like an explanation let me know.

Quote: "this is the problem ive been having:
Quote: "anywho, just in case, to try to make it more clear, the problem I'm having with the animations is that the game screws up when I have two animations for the same button (one of course has shift with it)""

I'd structure it like nonZero has with each condition in a new if statement. It's easier to follow...for me anyway.

Sazex
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location:
Posted: 6th Jan 2012 03:16
Quote: "If you'd like an explanation let me know."


If you can tell me what you did different, thatd be awesome

anyways well I did try this:


which I think is the same structure as his example, but it din't work , nonzero said to define variables right, I guess I could try that, but I didn't think itd make a difference

sazex
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 6th Jan 2012 04:04
Quote: "If you can tell me what you did different, thatd be awesome"

I actually made use of some of your code. You have this:

Which returns which object that collision statement is true for. So if that equals 2 then your character is colliding with the ground. So I simply added this to your current code:


and that's it.

Quote: "anyways well I did try this:"

Your logic looks ok actually. If my memory serves you only need to call the LOOP OBJECT command once for it to work, not multiple times. So you might need create a few more flags.

Try something like this:


Sazex
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location:
Posted: 6th Jan 2012 05:51
Wow, that does work!
cept if I walk, and stop, the "w" animation by itself does not work

btw so If I had three animations to play, I would do something like this:


sazex
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 6th Jan 2012 06:02
Quote: "cept if I walk, and stop, the "w" animation by itself does not work"

What happens?

Quote: "btw so If I had three animations to play, I would do something like this:"

Yep, and you can give your animation variables better names so you don't get confused.

Sazex
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location:
Posted: 6th Jan 2012 07:16 Edited at: 6th Jan 2012 07:16
Quote: "What happens?"

the game plays my idle animation
I have my idle animation play when no key is pressed

sazex
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 6th Jan 2012 08:24
Have you set up a flag for it like the other animations?

nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 6th Jan 2012 16:57
Quote: "Does defining variables for the numbers really change the outcome?"


No, it's not about the variable directly. It's about only having to call LOOP OBJECT once. This might prevent possible conflicts. You see KEYSTATE() only returns whether a key is being pressed. So it's possible for a conflict to be born, ie:

Keycheck for SHIFT + W = TRUE: Animate: Character running.
(however)
Keycheck for W = TRUE: Animate: Character walking

My understanding of LOOP OBJECT is that it internally monitors the frame it's on, so even if we have:

Keycheck for W = TRUE: Animate: Character walking
Keycheck for SHIFT + W = TRUE: Animate: Character running.

the internals for LOOP OBJECT are reset (because KEYSTATE() returned true on "w" but also "Shift + w"). But if we store the data ourselves and execute it AFTER the keycheck (correct structure permitting), the values for LOOP OBJECT don't change so the internals are not reset.

This is why you should only call LOOP OBJECT once per loop per object.


Hope that clarifies what I mean. Not so great at explaining stuff but the code should illustrate my point.

Sazex
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location:
Posted: 7th Jan 2012 06:17 Edited at: 7th Jan 2012 06:26
EDIT: ok I tried your thing nonzero,:



I didnt get the startani, so I just said loop object, and well that didn't work

for this one,



my program says "else" out of place (the second one), how do I define for three different animations or most probably 6 or 7

sazex
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 7th Jan 2012 10:05 Edited at: 7th Jan 2012 10:11
Quote: "ok I tried your thing nonzero,"

No, you tried your thing, sazex.
lol, couldn't resist that line

Quote: "I didnt get the startani, so I just said loop object, and well that didn't work"


... That was the whole point of the code. You use variables, any you want, you assign them values based on an input. You call the LOOP OBJECT function only once per cycle. I didn't want to get this technical, so I'll place my explanation in a code snippet:


I hope this explains it better. If not, just try perhaps just try doing it with variables and only one LOOP OBJECT call and see what happens.

Quote: "

my program says "else" out of place (the second one), how do I define for three different animations or most probably 6 or 7"


That's why we indent our code. You should take up Python for a while, it'll force you to make good habbits. Anyway:



I can't make sense of this except to assume things based on nesting levels.
Atm it seems you are missing 2 ENDIFs and
you are trying to use multiple ELSE's withing the same nest level.
You can't do this. ELSE is equivalent to NOT TRUE but provides a
way of truncating code to a single IF. Essentially, one could say
it's representative of a binary if, for example, IF = 1 then ELSE
= 0. Therefore you cannot present the computer with three-value or
more logic (theoretical things and fringe science aside). A
[normal] computer can only ever handle two-value logic. It
either is or it isn't. BUT we can manipulate this:
(scuse the bad formatting, when I posted, columns were cut off so I
added my own carraige returns)



Be careful with deep-nesting though. It's tough to debug, especially code that isn't indented correctly. Sometimes it's unavoidable, but in many cases there is an alternative.

Now I want a badge saying "Longest Post"

Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 7th Jan 2012 11:45
If the Loop Object command doesn't work out there is always the option of coding the animation looping yourself. I had to do this in one of my games once.

Sazex
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location:
Posted: 13th Jan 2012 07:24
Well, its been a few days before I tackled the animation thing, but Nonzero, I finally think I got around to trying out what you posted in your first code snippet, if this is what you meant:


that code above did the same thing as the other code I tried

anyways, I might have to turn to the nesting idea, I'll try what you posted, in a bit

sazex
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 13th Jan 2012 16:43
Quote: "if this is what you meant:"

Close, but not quite. There's still more than one LOOP OBJECT call. To use my method, "there can be only one" *insert dramatic music" LOOP OBJECT per cycle. You've two there, one at the start and one at the end. Move that one at the beginning above your DO to get things started.

Sazex
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location:
Posted: 17th Jan 2012 02:20
OK, I tried it, and it worked! Thanks nonZero, Finally me problems solved

sazex
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 17th Jan 2012 21:29
Good to hear and you're welcome.

Login to post a reply

Server time is: 2024-11-23 23:48:15
Your offset time is: 2024-11-23 23:48:15