Topic: Distance examples

here's 1 project with 3 levels about distance, pretty bad explained (or not at all) i'm afraid !
but if it can give you some ideas it's all good

Project

1) Calculate distance between meshes in percent
PunBB bbcode test


2) Radius collision detection, based on anael's method over here : http://forum.maratis3d.com/viewtopic.php?pid=6296#p6296
PunBB bbcode test


3) Spawn multiple clones in a given object perimeter
PunBB bbcode test

4) Spawn in Radius v2, will spawn animated texture at random positions on a controllable radius
PunBB bbcode test



Notes : I removed the object parenting in example 2, and use follow behavior instead

Last edited by Vegas (2014-06-15 18:17:39)

Re: Distance examples

that's awesome !

The Radius collision detection mproj is not connected to the correct level by default,
I just loaded the good level and it worked.

But I didn't managed to make the Spawn multiple clones level working.

Re: Distance examples

Ooops thanks for the feedback, i fixed that smile
for the third example i forgot to put instructions on screen, you needed to press "1" to spawn the clones

Im gonna add one or two more levels to this project later on,
a LookAt alternative like you suggested me a while back (with getLength3d(vec), normalize3d(vec) stuff)
and a mix-up of the 3 first examples

Oh and while i'm at it, for the first example, do you know if that's possible to
convert back the % value to position ?

I wanted to spawn clones between point A & B at a given % when launching the game,
(lets say 1 clones every 10%) but didn't succeed

Re: Distance examples

Nice!!! This solves my distance issue. I guess I can pick back up on that AI system.

I needed distance detection for the 5 senses, and also for the fuzzy logic I was trying to implement.

Re: Distance examples

So wait, I have a question, that DistancePercent thing has a box going from one point to another. So, I could use this to guide an object along a path then?

Also, the radius thing sort of acts like a wind system for particles.

Last edited by Tutorial Doctor (2014-06-15 14:57:33)

Re: Distance examples

Glad it helped wink

guide an object along a path

oh you need almost nothing to do this, from an empty project :

add 3 cubes, spread them, and name them :

Player
TargetA
TargetB

then put a LookAt behavior on the Player, with TargetA as target

and in script you could do

translate(Player, {0, 0, -1}, "local")

(negative value on Z axis on a object who got LookAt on it, will always move toward his target)

And when it reaches TargetA and collide with physics, distance or whatever, change behavior to
setBehaviorVariable(Player, 0, "target", "TargetB")

I will update the 2nd and 3nd examples this evening, while i was fighting with my projects i got some ideas smile

Re: Distance examples

to convert % in position, just use the start and end positions :

- convert your % to a number between 0 and 1 : factor = percent*0.01
- then : pos = start_pos + (end_pos - start_pos)*factor

Re: Distance examples

So something like?:

person = getObject("Person")
building = getObject("Building")
building2 = getObject("Building2")

--Person object should have LookAt behavior
translate(Person,{0,0,-1},"local)

if isCollisionBetween(person,building) then
    setBehaviorVariable(Person,0,"target","building2")
end

http://wiki.maratis3d.org/index.php?tit … orVariable

I will check this out later. Thanks.

Re: Distance examples

@TD, Yep, something like this (but take care it can be troublesome
to use on characters because it will then face the ground tongue)

@Anael, Outstanding ! Thank you wink

Re: Distance examples

Okay Sir Vegas, those explosions are awesome!!! What was your method?

Re: Distance examples

There it is, Lord TD big_smile

This particular explosion comes from a application called Particle Illusion
but basically my method is :

1) use a Imagemagick script to pack individual frames in a spritesheet
2) loading the texture into blender (i have a template for animating textures)
3) export. thats it

I have now a pretty decent collection of animated textures, with some found
on OGA, Deviant Art, and some others made with generators,I was planning to make a pack
of these but i could never decide if i put :

1) Multiple animations on a single texture
= Easier to manage, less easier to use, not really tweakable afterward (or painfully)

or

2) One texture per animations (so 1 different mesh for each anims)
= Easier to use, less easier to manage, easily tweakable

+ with maratis MGUI that will use FreeImage library, maybe i can use better resolution, easier workflow, i dont know, maybe it's better to wait a bit

Re: Distance examples

Hi all! great examples, Vegas!

Here is my function of receiving a distance:

function distance(entity1,entity2)
    local pos1 = (getTransformedPosition(entity1))
    local pos2 = (getTransformedPosition(entity2))
    return (math.sqrt(math.abs(math.pow((pos2[1]-pos1[1]),2)+math.pow((pos2[2]-pos1[2]),2) ) ) )
end
--the function call:
--1)
print(distance(player, enemy))

--2)
if distance(player, enemy) < 100 then
    --
end

if it is someone useful, can lay out other functions.

Last edited by ant0n (2014-06-16 12:25:29)

Re: Distance examples

Hey, I went looking for generators, and the first one I came across was this:

http://www.saschawillems.de/?page_id=253

Looks promising.

All I need to know now is how to export this animation, but I think I saw a tutorial either here or on the wiki.

Last edited by Tutorial Doctor (2014-06-16 15:56:32)

Re: Distance examples

@ant0n, Thanks for posting ! the more methods we have, the better smile

@TD, Yeah it's a good one, what i really like with that app is you can feed it directly with png files, i had some nice results out of it, however tweaking the effet was kinda troublesome, i should try again

About the animated texture tutorial, there's a lot of info you don't even need in it, i'm gonna remake it right now
keep you in touch

Edit : Early rewrite of the tut :
http://forum.maratis3d.com/viewtopic.php?pid=365#p365

Last edited by Vegas (2014-06-16 22:31:24)