First object jumps on re-entry of second colliding object

The scenario is that I have two objects – Object A and Object B. The Object A is lying on the ground and when Object B enters the collider of Object A, the Object A moves (only X and Z axis) with Object B. The movement works well with the script shown below.

The issue is that most of the time, the Object A’s initially position shifts by few meters whenever Object B enters its collider. I feel it is related to offset position. What should happen is that, Object A should be the same position when Object B enters the collider and move along with Object B only when Object B moves.

So how do I fix this?

private Vector3 offsetPosition;  public Transform ObjectB;  public bool ObjectB_Collision = false;  void Start () {         offsetPosition = ObjectB.transform.position - this.transform.position;     }      void ObjectB_HasEntered() {         offsetPosition = ObjectB.transform.position - this.transform.position;     }       // Update is called once per frame     void LateUpdate () {          if (ObjectB_Collision == true) {             this.transform.position = new Vector3 (ObjectB.transform.position.x, this.transform.position.y, ObjectB.transform.position.z) - new Vector3 (offsetPosition.x, 0, offsetPosition.z);         }      }  public void OnTriggerEnter (Collider col) {         if (!enabled) return;          if (col.gameObject.name == "Object_B") {             ObjectB_HasEntered();             ObjectB_Collision = true;         }     }   public void OnTriggerExit (Collider col) {         if (!enabled) return;         if (col.gameObject.name == "Object_B") {             ObjectB_Collision = false;          }     } ``` 

Poisson GeneralizedLinearModelFit with log link, first argument not a vector, matrix or list

Question:

I’m trying to plot a graph for an exponential decay for a radioactivity experiment, so model is y=Ae^(-kt). Cross-Validated SE, suggested trying a Poisson GLM with a log link fit, and then to output mean deviance for goodness of fit. I’ve tried doing this but am getting the error:

GeneralizedLinearModelFit::notdata: The first argument is not a vector,  matrix, or a list containing a design matrix and response vector. 

And admittedly, I don’t really understand the documentation for it. And am unsure how to implement the show mean residuals part of this. The documentation shows how to output all of the deviance residuals, but not the mean of them directly.

Data

dataHist5 = {{Around[16.5, 1.5],     Around[77.8, 8.8]}, {Around[34.5, 1.5],     Around[60.5, 8.0]}, {Around[52.5, 1.5],     Around[63.8, 8.0]}, {Around[106.5, 1.5],     Around[42.4, 6.5]}, {Around[124.5, 1.5],     Around[41.7, 6.5]}, {Around[142.5, 1.5],     Around[14.6, 3.8]}, {Around[160.5, 1.5],     Around[33.9, 5.8]}, {Around[178.5, 1.5],     Around[29.4, 5.4]}, {Around[196.5, 1.5],     Around[33.5, 5.8]}, {Around[214.5, 1.5],     Around[30.9, 5.6]}, {Around[232.5, 1.5],     Around[31.1, 5.8]}, {Around[250.5, 1.5],     Around[21.5, 4.6]}, {Around[268.5, 1.5],     Around[4.3, 2.1]}, {Around[286.5, 1.5],     Around[6.4, 2.5]}, {Around[322.5, 1.5],     Around[7.5, 2.7]}, {Around[340.5, 1.5],     Around[4.5, 2.1]}, {Around[358.5, 1.5],     Around[11., 3.3]}, {Around[376.5, 1.5],     Around[14.0, 3.7]}, {Around[394.5, 1.5],     Around[14.0, 3.7]}, {Around[466.5, 1.5],     Around[0.6, 0.7]}, {Around[502.5, 1.5],     Around[2.2, 1.5]}, {Around[520.5, 1.5],     Around[9.4, 3.1]}, {Around[538.5, 1.5],     Around[4.1, 2.0]}, {Around[646.5, 1.5],     Around[2.2, 1.5]}, {Around[682.5, 1.5], Around[0.6, 0.7]}} 

Code, so far:

glm = GeneralizedLinearModelFit[dataHist5, x, x,     ExponentialFamily -> "Poisson"] // Normal Show[ListPlot[dataHist5, Plot[glm[x]]] 

I think I’m missing an argument in Plot[glm[x]]], but not sure what.

How to get sale product first on category listing page woocommerce?

I want to sort product on category listing page. Want to display sale product first and remaning product after sale product. I have used woocommerce_get_catalog_ordering_args hook for sorting but not working.

My code looks like this

function catalog_ordering_args( $  args ) {     if( !is_product_category() ){         return $  args;     }      $  args['orderby'] = 'meta_value_num';     $  args['order'] = 'ASC';     $  args['meta_key'] = '_sale_price';      return $  args; } add_filter( 'woocommerce_get_catalog_ordering_args', 'catalog_ordering_args', 20, 1 ); 

It should also work for variation products

meta query regexp only work with first two characters

I have a meta query to return data based on the input value. Here I get value like this Tm-university-brazil,

now I replace the dash with space so it becomes Tm university brazil, but the search does not work, it only works if put ‘Tm’ in search it does not work when ‘Tm university brazil’.

if (isset($  uni_name)  && !empty($  uni_name)  ) {  $  uni_name = str_replace('-'," ",$  uni_name);       $  meta[] = array(             'key'     => 'uniname',             'value'   => $  uni_name,             'compare' => 'REGEXP',                  );  } 

Pointers on making my first ever video [closed]

I have had a love for video games for years. Hack and slash, rpg, mmorpg, racing, first and thrid person shooters, and open world, story driven games. I’m looking to start in making my own and first ever game. I will be doing this by myself, on my own time, and my own money, so I’m doing this for mainly practice and honing my skills, so no big, overly ambitious ideas yet, but I’m looking for what would be a good program to start breaking ground in training myself in making video games and being able upload them.

Pointers for making my first video game [closed]

I have had a love for video games for years. Hack and slash, rpg, mmorpg, racing, first and thrid person shooters, and open world, story driven games. I’m looking to start in making my own and first ever game. I will be doing this by myself, on my own time, and my own money, so I’m doing this for mainly practice and honing my skills, so no big, overly ambitious ideas yet, but I’m looking for what would be a good program to start breaking ground in training myself in making video games and being able upload them.

Demon of the First Circle limitations

Demon of the First Circle or any of the Demon spells seems ripe for exploitation. I’m wondering how other storytellers have dealt with this issue.

I’m worried because of the ease of summoning, and the length the demon will serve you. The way I read the rules there is nothing preventing a sorcerer from summoning one demon every night. The risk of failing Int + Occult vs the demons resolve is also very small. Spend willpower and a stunt, and you’re almost guaranteed to succeed. That is before taking into consideration that most sorcerers will have high int and occult, and possibly an excellency to boost the roll if they feel like it. Once summoned the demon is your slave for a year and a day.

Given the system, it feels like most sorcerers should be surrounded by a small army of demons to do their bidding.

How have other storytellers dealt with this issue? Is there anything from e3 or the other editions that can be used as a guide to reduce the exploitability of the summon spells?

How to get your first 1d6 sneak attack without class levels?

There are numerous ways to get additional d6’s worth of sneak attack, but almost all of them require that you have 1d6 (or more) sneak attack before you can take them. How does one get +1d6 sneak attack damage from non-level sources when one has no sneak attack?

There is at least one way—Martial Stance (assassin’s stance) from Tome of Battle, which actually gives +2d6—but that isn’t available until 12th or (if the DM is generous) maybe 9th, and requires another feat besides.

  • Any Wizards of the Coast published 3.5e material, as well as any 3.5e content from Dragon and Dungeon magazines, is legitimate.
  • While stuff earlier than Martial Stance’s 12th is preferred, any content available pre-epic is acceptable.
  • Epic content is not allowed, even if you somehow cheese into it prior to epic levels.
  • Any kind of polymorph or shape changing is not allowed.
  • The sneak attack must be available on a continuous, permanent basis. A magic item is acceptable, as is a 24-hour daily effect (e.g. spell), but not anything less than that.
  • Persistent Spell, and any other means of turning a less-than-24-hour-duration spell into a 24-hours duration spell, are not allowed.
  • LA counts as “levels” for this purpose, as do RHD. No ECL can be consumed by a valid answer.
  • Bloodlines are not allowed.
  • Any form of “undoing” levels (e.g. level loss from energy drain or resurrection, curing lycanthropy, various rituals) is not allowed.
  • No assumptions about which classes are taken may be made, though you may leave achieving the necessary BAB/saves/skill ranks as an exercise for the reader so long as they’re non-epic values.

Really, what I want is feats and/or magic items that just say “you gain +1d6 [or more] sneak attack,” not some kind of shenanigan. Assassin’s stance proves it exists, and I’m fairly confident there’s some more out there (some named magic weapons, IIRC?). If you’re inclined to suggest a shenanigan, you may be well served running it by me in a comment before you spend your time—I have made every effort to provide a thorough list of the things I’m against, but if an answer manages to prove me wrong, I’m still not going to be happy with the shenanigan.