Not logged inOpenClonk Forum
Up Topic General / Help and Questions / How to get kind of hit object
- - By Kandif [pl] Date 2014-11-19 15:17
Hwo to take kind of hit object: landscape or clonk.

For example:

protected func Hit(){

if(hit ladscape){
    nothing
}

if(hit clonk){
   explode
}

}
Parent - By Clonkonaut [de] Date 2014-11-19 15:25
Hit() is only called when hitting solid ground (i.e. the landscape). You don't get a callback in the hitting object when it hits a clonk. But you get a callback to the clonk getting hit: QueryCatchBlow(object by) (see here for all calls made from the engine)
You could use that call in the clonk to make a call to the object (by).
Reply
Parent - By Pyrit Date 2014-11-19 18:27
Maybe you want to have a look at the arrow.

If you add the effect AddEffect("HitCheck", this, 1,1, nil,nil, shooter); and it hits an object public func HitObject(object obj) is called. So you could try:

func Initialize()
{
  AddEffect("HitCheck", this, 1,1, nil,nil, shooter);
}

func HitObject(object obj)
{
  Explode(10);
}
Parent - - By Newton [de] Date 2014-11-19 21:56
There is no trivial way to do it because the concept of hit does not exist for objects with objects - e.g. several rocks would fly past each other.

But of course, as anything else you can implement this in script by checking each frame if at the position of the object, there is another object. This has already been done for objects like the arrow. See Pyrit. Note though that you should probably add the effect when your object is thrown (exits it's container) and pass the container object to the hit check effect. Otherwise, the hit check would find the clonk that throws the object right away and explode on his hands :-). Like this:

func Departure(object container)
{
  if(container
AddEffect("HitCheck", this, 1,1, nil,nil, container);
}
Parent - By Pyrit Date 2014-11-19 22:41

>the hit check would find the clonk that throws the object right away and explode on his hands :-)


Mh yeah, right. And maybe test for velocity so it doesn't explode so it doesn't explode when it stands still.
Up Topic General / Help and Questions / How to get kind of hit object

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill