Fangames > Programming Questions

Little Spike Thing question

(1/2) > >>

PikachuLPer:
How do i make like spikes when i jump it comes out the floor and if i jump again it goes back to the floor like in boshy?

Thanks

lawatson:
So, being the logical but not entirely efficient coder I am, I compiled this little sinewave-based object according to what I assumed your demand is (jump-enabled in and out spikes). The code is here: (pre-hotfix please look down)  https://pastebin.com/8v18zg58

The downfall as far as I can tell is that it doesn't properly transition if you jump fast enough, but it should never "break" or throw an error by any means. I'll get working on a better version, though. Tell me how you like the one I showed.

Edit: If they aren't going in and out fast enough to your liking, go to the sineAngle code and change the "+4" to a higher number, preferably between 10 and 15.

EditEdit: If you're using studio, there's gonna be some variable-related errors. If that happens, put in the Create Event as follows:

transitioning=0;
way=0;
sineAngle=0;

And that should be it..?

EditEditEditings!!!EditSuperEditVersionCyberHitBoxEdition:

I suppose I really should get better at actually thinking about what my stuff does. Okay, so set "way=1" in the creation CODE of spikes that are on the second wave of jumping, and copy THIS hotfix code instead: https://pastebin.com/a0LmTW3q

PikachuLPer:
there is a problem with that script

___________________________________________
FATAL ERROR in
action number 1
of Create Event
for object spikeDownMove:

COMPILATION ERROR in code action
Error in code at line 9:
       x=lerp(sX,tX,1);
         ^
at position 8: Unknown function or script: lerp

lawatson:
Shite! I always forget that people don't have the lerp function for some reason. I wonder why.

Anyways, just make a script called "lerp" I suppose, and put this in it:

return (argument0+(argument1*argument2)-(argument0*argument2));

PikachuLPer:
Im trying that for spike down but if i jump it goes to the left? and then back if i hold the jump button its just moving left and back without stopping if i let the button go it stops.

Navigation

[0] Message Index

[#] Next page

Go to full version