CF78's Forum Posts

  • You do not have permission to view this post

  • You do not have permission to view this post

  • You do not have permission to view this post

  • You do not have permission to view this post

  • You do not have permission to view this post

  • You do not have permission to view this post

  • You do not have permission to view this post

  • You do not have permission to view this post

  • You do not have permission to view this post

  • You do not have permission to view this post

  • You do not have permission to view this post

  • You do not have permission to view this post

  • Nesteris

    [quote:p0fplsk0]s * dt

    That would like "value + s * dt" right? I just want to be sure without a doubt

    If we used say, bullet behaviour or platform behaviour. Do we need to make events to add dt to the behaviour values or are they already incorporated?

    It seems from the updated tutorial that all behaviors already use dt. Except for the physics behavior.

  • Refeuh

    Thank you very much! I appreciate that

    great art work, btw, I checked the links in your signature, very nice !

    Unrolling the x & y you end up with :

    dir.x = Player.ImagePoint.X - Gun.Pos.X

    dir.y = Player.ImagePoint.Y - Gun.Pos.Y

    dirLength = sqrt(dir.x^2 + dir.y^2)

    v.x = dir.x / dirLength

    v.y = dir.y / dirLength

    Gun.pos.x = Gun.pos.x + Gun.speed*dt*v.x

    Gun.pos.y = Gun.pos.y + Gun.speed*dt*v.y

    I don't fully understand this but, I think once I apply it and see it in action my visual brain will begin to grasp it.

  • Refeuh

    No worries and no need to apologize! I just want to let you know my level of understanding

    Every tick, if the Gun.pos is far from Player.ImagePoint

    compute direction dir towards the destination : dir = Player.ImagePoint - Gun.pos

    compute normalised vector v towards the destination : v = v/v.length (so that this vector has a length of 1)

    move Gun along v depending on its speed and dt : Gun.pos = Gun.pos + Gun.speed*dt*v

    for good effect, add a clamp() to make sure you don't overshoot if the gun is already close to the mount point

    This definitely helps for my understanding. Though with this approach I assume I will have to create 2 vectors for vertical and horizontal positioning?

    Thanks for the infos!