![]() |
?keeping the player from going on walls
I'm trying to find SOME way to keep the player from freezing (not being able to move) or going into the wall.
momentumx is how fast the player is moving toward the wall. When the player hits the wall they are redirected into the other direction. bounceloss is how much momentum is lost when the player is redirected off the wall. --I'm also going to remove the freezeplayer in this script sooner or later. NPC Code: Edit-- I don't care about vectors. |
You know there's a difference between speed and momentum, right?
|
yes, but momentum=speed in this script.
|
They might have the same values in this case, but that doesn't make them the same thing.
Incidentally, increasing the magnitude of two components of a vector by a certain constant does not merely increase the composite vector's magnitude by the same amount. Worse than that, it also changes the direction of the vector. Just a heads up. BTW: KSI-GS |
so, are you saying don't try using vectors for this? I've completely forgotten vectors since the last time I used it. something about <x+,y+> or something.
|
Quote:
|
Quote:
I understand that I am changing the direction of the player. If I werent changing the direction he would be going through the wall (which it does sometimes anyways). I think I might have just thought of a solution, to the effect that I want. Maybe if I tested when the player was close to a wall and replaced momentum temporarily with the distance from the wall... wait... figures... how am i supposed to find the distance from the wall? I would try cutting momentum in half each time it doesn't detect but that most likely wouldn't give the desired effect... Why couldn't stefan have made this easier? |
Quote:
Quote:
Quote:
Oh, and non-prefixed variables are volatile. If you require a variable to retain its value between frames, prefix it with a 'this'. |
Quote:
if (this.momentumy <= 0&&this.momentumy >= -friction){ this.momentumy = 0; } if (this.momentumy >= 0&&this.momentumy <= friction){ this.momentumy = 0; } if (this.momentumx <= 0&&this.momentumx >= -friction){ this.momentumx = 0; } if (this.momentumx >= 0&&this.momentumx <= friction){ this.momentumx = 0; } I guess I do misunderstand. I thought that adding this would check it. --Do you mean this is a bad way to check it? Quote:
Edit-- It's a shame that I didn't make this to be an airplane script.. Then I wouldn't have to bother with player speed (haven't bothered with yet but will probably be a pain) and onwall. |
From newfeatures2003-v3.txt:
Quote:
|
Quote:
1) Moving diagonally increases the player's speed more quickly than solely moving in any of the four main directions. 2) If the player moves diagonally, he/she can travel ~1.4 times faster than normal. There are also other problems. The onwall check, for example, is inaccurate. The response to the detection of the wall is flawed too. Application of KSI-GS could fix it, but I guess you don't care about that any more than you care about vectors. Quote:
|
Quote:
|
you can save it in v2 and then open v3... but it seems to have the same effect as the one I was using before.
Quote:
Quote:
Quote:
Quote:
I am NOT very accustomed to making scripts as I believe that you probably are. I deny that I am a good scripter if anyone believes that I am. I am better with ideas than I am with putting them into effective scripts. --Just ask Kat, he'll tell you that I'm bad at explaining ideas, too. |
Quote:
Quote:
Quote:
Quote:
|
Quote:
Quote:
Quote:
Quote:
|
Quote:
Quote:
Quote:
|
Listen to Kai and his vector talk, then do research. In addition to learning about vectors, you can learn alot of other useful stuff. It took me about a year to understand "Kai-Talk", because it took me a year to think about research on all scripts before attempting them to get insight from programmers, and to research on maths I know I will need in scripts, which I do not already know.
Don't make the same mistake =P. |
Don't get mad at Kai, he's telling the truth, you're just not understanding (which is pretty much understandable). Let me clarify for you, you have two major problems with the code;
1. there are quite a few more lines than there needs to be, meaning you can break down all those separate if checks for each direction into a for loop, but I'll let you figure how to fix that on your own 2. your wall check is highly innacurate, it only checks immediately, well actually I have no idea where you were going with those numbers... but it would greatly improve upon your script to do some dynamic checking, meaning you should check the area the player will be moving to before you actually send him/her there using your "momentum" variables and playerx/y oh and vecx/vecy are your friends when using for loops to compile directional scripts |
Quote:
I don't like kai because he was straying off of my question. Something that I should say to kai: I know about the other problems it's just that i'm dealing with them one at a time. |
Yes, any help that doesn't follow your exact specifications is evil and venemous.
|
| All times are GMT +2. The time now is 08:15 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.