Home Tutorials Download Beta Store Forum Documentation KnowledgeBase Wiki Blog

ShiVa3D

Return to Game programming

Noob 2D Movement Question?

All about the StoneScript

Re: Noob 2D Movement Question?

Postby Guinner » 09 Apr 2012, 09:45

Is there a problem you can't solve?
This is amazing thank you! I've implemented the code into my game, changing quite a bit of it to match my needs but this is the perfect example! Thank you :)
Guinner
Junior Boarder
Junior Boarder
 
Posts: 36

Re: Noob 2D Movement Question?

Postby DoctorPepper » 15 Apr 2012, 06:08

Keep getting AI Runtime error : [State] AI_Hero.Move_onLoop: attempt to compare number with nil (nHitDist)

logged the value nHitDist. Always get 1 value above 0.7, next line is a crash in
if(this.bJumping ( ) == false and nHitDist > 0.7 )

weird stuff.
User avatar
DoctorPepper
Platinum Boarder
Platinum Boarder
 
Posts: 474
Location: Belgium

Re: Noob 2D Movement Question?

Postby broozar » 15 Apr 2012, 09:38

do you use 1.9.1? nHitDist returns 0 for me if the ray does not hit anything, not nil.
in any case case, put a

Code: Select all
if hHitObject~= nil then
    --the code in question
end


around it.
User avatar
broozar
Platinum Boarder
Platinum Boarder
 
Posts: 3455
Location: Berlin - Germany

Re: Noob 2D Movement Question?

Postby DoctorPepper » 15 Apr 2012, 13:55

Must be it, i am still using the old good 1.9.0.1
Raycast is all messed up, when the object is in mid air, it keeps returning nil so the object is stuck there. when i move at high speed and hit something, it moves in z axis so the object flyes of the 2d level. (is there a way to limit the z movement?)

edit: srr, it seems ive been using nHit instead of hHit. But the problem with z movement remains
User avatar
DoctorPepper
Platinum Boarder
Platinum Boarder
 
Posts: 474
Location: Belgium

Re: Noob 2D Movement Question?

Postby broozar » 15 Apr 2012, 17:34

well, please post your entire code then, or preferably an STE, and i will have a look at it.
and i can't tell which axis is z for you - forward/backward or front/back...
User avatar
broozar
Platinum Boarder
Platinum Boarder
 
Posts: 3455
Location: Berlin - Germany

Previous

Return to Game programming